From cdf0a95035db6dbb4ea94fa846761a1831f72648 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Fri, 6 Nov 2020 16:40:39 +0200 Subject: [PATCH] Edit & forward original date in message time title --- src/components/chat/messageRender.ts | 13 +++++++++++-- src/helpers/date.ts | 5 +++++ src/lib/appManagers/appDialogsManager.ts | 5 +++-- src/scss/partials/_chatBubble.scss | 3 +++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/components/chat/messageRender.ts b/src/components/chat/messageRender.ts index bc3e619b..ce2e1235 100644 --- a/src/components/chat/messageRender.ts +++ b/src/components/chat/messageRender.ts @@ -1,3 +1,5 @@ +import { getFullDate } from "../../helpers/date"; +import RichTextProcessor from "../../lib/richtextprocessor"; import { formatNumber } from "../../lib/utils"; type Message = any; @@ -12,8 +14,10 @@ export namespace MessageRender { let time = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2); if(message.views) { + const postAuthor = message.post_author || message.fwd_from?.post_author; + bubble.classList.add('channel-post'); - time = formatNumber(message.views, 1) + ' ' + time; + time = formatNumber(message.views, 1) + ' ' + (postAuthor ? RichTextProcessor.wrapEmojiText(postAuthor) + ', ' : '') + time; if(!message.savedFrom) { const forward = document.createElement('div'); @@ -35,9 +39,14 @@ export namespace MessageRender { time = 'edited ' + time; } + const title = getFullDate(date) + + (message.edit_date ? `\nEdited: ${getFullDate(new Date(message.edit_date * 1000))}` : ''); + + (message.fwd_from ? `\nOriginal: ${getFullDate(new Date(message.fwd_from.date * 1000))}` : ''); + const timeSpan = document.createElement('span'); timeSpan.classList.add('time', 'tgico'); - timeSpan.innerHTML = `${time}
${time}
`; + timeSpan.title = title; + timeSpan.innerHTML = `${time}
${time}
`; messageDiv.append(timeSpan); diff --git a/src/helpers/date.ts b/src/helpers/date.ts index d30fe2a1..2b78b9f9 100644 --- a/src/helpers/date.ts +++ b/src/helpers/date.ts @@ -29,4 +29,9 @@ export const formatDateAccordingToToday = (time: Date) => { } return timeStr; +}; + +export const getFullDate = (date: Date) => { + return date.getDate() + ' ' + months[date.getMonth()] + ' ' + date.getFullYear() + + ', ' + ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2) + ':' + ('0' + date.getSeconds()).slice(-2); }; \ No newline at end of file diff --git a/src/lib/appManagers/appDialogsManager.ts b/src/lib/appManagers/appDialogsManager.ts index ebe89ea1..dd4d0bbf 100644 --- a/src/lib/appManagers/appDialogsManager.ts +++ b/src/lib/appManagers/appDialogsManager.ts @@ -545,8 +545,9 @@ export class AppDialogsManager { } public setListClickListener(list: HTMLUListElement, onFound?: () => void, withContext = false) { - list.addEventListener('click', (e: Event) => { - cancelEvent(e); + list.addEventListener('mousedown', (e) => { + if(e.button != 0) return; + //cancelEvent(e); this.log('dialogs click list'); let target = e.target as HTMLElement; diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss index c17d6ec4..3499b9d9 100644 --- a/src/scss/partials/_chatBubble.scss +++ b/src/scss/partials/_chatBubble.scss @@ -1020,6 +1020,7 @@ $bubble-margin: .25rem; align-items: center; padding: 0 2.5px; line-height: 20px; + pointer-events: all; // show title .inner { display: none; @@ -1034,6 +1035,7 @@ $bubble-margin: .25rem; user-select: none; line-height: 1; vertical-align: middle; + pointer-events: none; // do not show title /* display: inline-flex; align-items: center; */ @@ -1049,6 +1051,7 @@ $bubble-margin: .25rem; } .inner { + pointer-events: all; position: absolute; bottom: 0; right: 0;