Browse Source

Edit & forward original date in message time title

master
morethanwords 4 years ago
parent
commit
cdf0a95035
  1. 13
      src/components/chat/messageRender.ts
  2. 5
      src/helpers/date.ts
  3. 5
      src/lib/appManagers/appDialogsManager.ts
  4. 3
      src/scss/partials/_chatBubble.scss

13
src/components/chat/messageRender.ts

@ -1,3 +1,5 @@
import { getFullDate } from "../../helpers/date";
import RichTextProcessor from "../../lib/richtextprocessor";
import { formatNumber } from "../../lib/utils"; import { formatNumber } from "../../lib/utils";
type Message = any; type Message = any;
@ -12,8 +14,10 @@ export namespace MessageRender {
let time = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2); let time = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
if(message.views) { if(message.views) {
const postAuthor = message.post_author || message.fwd_from?.post_author;
bubble.classList.add('channel-post'); bubble.classList.add('channel-post');
time = formatNumber(message.views, 1) + ' <i class="tgico-channelviews"></i> ' + time; time = formatNumber(message.views, 1) + ' <i class="tgico-channelviews"></i> ' + (postAuthor ? RichTextProcessor.wrapEmojiText(postAuthor) + ', ' : '') + time;
if(!message.savedFrom) { if(!message.savedFrom) {
const forward = document.createElement('div'); const forward = document.createElement('div');
@ -35,9 +39,14 @@ export namespace MessageRender {
time = '<i class="edited">edited</i> ' + time; time = '<i class="edited">edited</i> ' + 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'); const timeSpan = document.createElement('span');
timeSpan.classList.add('time', 'tgico'); timeSpan.classList.add('time', 'tgico');
timeSpan.innerHTML = `${time}<div class="inner tgico">${time}</div>`; timeSpan.title = title;
timeSpan.innerHTML = `${time}<div class="inner tgico" title="${title}">${time}</div>`;
messageDiv.append(timeSpan); messageDiv.append(timeSpan);

5
src/helpers/date.ts

@ -30,3 +30,8 @@ export const formatDateAccordingToToday = (time: Date) => {
return timeStr; 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);
};

5
src/lib/appManagers/appDialogsManager.ts

@ -545,8 +545,9 @@ export class AppDialogsManager {
} }
public setListClickListener(list: HTMLUListElement, onFound?: () => void, withContext = false) { public setListClickListener(list: HTMLUListElement, onFound?: () => void, withContext = false) {
list.addEventListener('click', (e: Event) => { list.addEventListener('mousedown', (e) => {
cancelEvent(e); if(e.button != 0) return;
//cancelEvent(e);
this.log('dialogs click list'); this.log('dialogs click list');
let target = e.target as HTMLElement; let target = e.target as HTMLElement;

3
src/scss/partials/_chatBubble.scss

@ -1020,6 +1020,7 @@ $bubble-margin: .25rem;
align-items: center; align-items: center;
padding: 0 2.5px; padding: 0 2.5px;
line-height: 20px; line-height: 20px;
pointer-events: all; // show title
.inner { .inner {
display: none; display: none;
@ -1034,6 +1035,7 @@ $bubble-margin: .25rem;
user-select: none; user-select: none;
line-height: 1; line-height: 1;
vertical-align: middle; vertical-align: middle;
pointer-events: none; // do not show title
/* display: inline-flex; /* display: inline-flex;
align-items: center; */ align-items: center; */
@ -1049,6 +1051,7 @@ $bubble-margin: .25rem;
} }
.inner { .inner {
pointer-events: all;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
right: 0; right: 0;

Loading…
Cancel
Save