From 59d588a5e6d07da7f1af6f7d50862440107539d5 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Thu, 27 Jan 2022 09:36:13 +0400 Subject: [PATCH] 2 --- src/components/chat/bubbles.ts | 10 ++++++++-- src/components/chat/messageRender.ts | 20 ++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index f99309ce..50a4908d 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -2700,12 +2700,18 @@ export default class ChatBubbles { if(needToSetHTML) { setInnerHTML(messageDiv, richText); } - - const timeSpan = MessageRender.setTime(this.chat, message, bubble, bubbleContainer, messageDiv); + + const timeSpan = MessageRender.setTime({ + chatType: this.chat.type, + message + }); + messageDiv.append(timeSpan); bubbleContainer.prepend(messageDiv); //bubble.prepend(timeSpan, messageDiv); // that's bad if(isMessage && message.views) { + bubble.classList.add('channel-post'); + if(!message.fwd_from?.saved_from_msg_id && this.chat.type !== 'pinned') { const forward = document.createElement('div'); forward.classList.add('bubble-beside-button', 'forward', 'tgico-forward_filled'); diff --git a/src/components/chat/messageRender.ts b/src/components/chat/messageRender.ts index 93f31f5b..28f41bd0 100644 --- a/src/components/chat/messageRender.ts +++ b/src/components/chat/messageRender.ts @@ -12,7 +12,7 @@ import RichTextProcessor from "../../lib/richtextprocessor"; import { LazyLoadQueueIntersector } from "../lazyLoadQueue"; import PeerTitle from "../peerTitle"; import { wrapReply } from "../wrappers"; -import Chat from "./chat"; +import Chat, { ChatType } from "./chat"; import RepliesElement from "./replies"; const NBSP = ' '; @@ -31,7 +31,11 @@ export namespace MessageRender { }; */ - export const setTime = (chat: Chat, message: Message.message | Message.messageService, bubble: HTMLElement, bubbleContainer: HTMLElement, messageDiv: HTMLElement) => { + export const setTime = (options: { + chatType: ChatType, + message: Message.message | Message.messageService, + }) => { + const {chatType, message} = options; const date = new Date(message.date * 1000); const args: (HTMLElement | string)[] = []; @@ -45,8 +49,6 @@ export namespace MessageRender { if(message.views) { const postAuthor = message.post_author || message.fwd_from?.post_author; - bubble.classList.add('channel-post'); - const postViewsSpan = document.createElement('span'); postViewsSpan.classList.add('post-views'); postViewsSpan.innerHTML = formatNumber(message.views, 1); @@ -62,15 +64,11 @@ export namespace MessageRender { } } - if(message.edit_date && chat.type !== 'scheduled' && !message.pFlags.edit_hide) { - bubble.classList.add('is-edited'); - + if(message.edit_date && chatType !== 'scheduled' && !message.pFlags.edit_hide) { args.unshift(editedSpan = makeEdited()); } - if(chat.type !== 'pinned' && message.pFlags.pinned) { - bubble.classList.add('is-pinned'); - + if(chatType !== 'pinned' && message.pFlags.pinned) { const i = document.createElement('i'); i.classList.add('tgico-pinnedchat', 'time-icon'); args.unshift(i); @@ -113,8 +111,6 @@ export namespace MessageRender { timeSpan.append(inner); - messageDiv.append(timeSpan); - return timeSpan; };