Eduard Kuzmenko 3 years ago
parent
commit
59d588a5e6
  1. 10
      src/components/chat/bubbles.ts
  2. 20
      src/components/chat/messageRender.ts

10
src/components/chat/bubbles.ts

@ -2700,12 +2700,18 @@ export default class ChatBubbles {
if(needToSetHTML) { if(needToSetHTML) {
setInnerHTML(messageDiv, richText); 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); bubbleContainer.prepend(messageDiv);
//bubble.prepend(timeSpan, messageDiv); // that's bad //bubble.prepend(timeSpan, messageDiv); // that's bad
if(isMessage && message.views) { if(isMessage && message.views) {
bubble.classList.add('channel-post');
if(!message.fwd_from?.saved_from_msg_id && this.chat.type !== 'pinned') { if(!message.fwd_from?.saved_from_msg_id && this.chat.type !== 'pinned') {
const forward = document.createElement('div'); const forward = document.createElement('div');
forward.classList.add('bubble-beside-button', 'forward', 'tgico-forward_filled'); forward.classList.add('bubble-beside-button', 'forward', 'tgico-forward_filled');

20
src/components/chat/messageRender.ts

@ -12,7 +12,7 @@ import RichTextProcessor from "../../lib/richtextprocessor";
import { LazyLoadQueueIntersector } from "../lazyLoadQueue"; import { LazyLoadQueueIntersector } from "../lazyLoadQueue";
import PeerTitle from "../peerTitle"; import PeerTitle from "../peerTitle";
import { wrapReply } from "../wrappers"; import { wrapReply } from "../wrappers";
import Chat from "./chat"; import Chat, { ChatType } from "./chat";
import RepliesElement from "./replies"; import RepliesElement from "./replies";
const NBSP = ' '; 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 date = new Date(message.date * 1000);
const args: (HTMLElement | string)[] = []; const args: (HTMLElement | string)[] = [];
@ -45,8 +49,6 @@ export namespace MessageRender {
if(message.views) { if(message.views) {
const postAuthor = message.post_author || message.fwd_from?.post_author; const postAuthor = message.post_author || message.fwd_from?.post_author;
bubble.classList.add('channel-post');
const postViewsSpan = document.createElement('span'); const postViewsSpan = document.createElement('span');
postViewsSpan.classList.add('post-views'); postViewsSpan.classList.add('post-views');
postViewsSpan.innerHTML = formatNumber(message.views, 1); postViewsSpan.innerHTML = formatNumber(message.views, 1);
@ -62,15 +64,11 @@ export namespace MessageRender {
} }
} }
if(message.edit_date && chat.type !== 'scheduled' && !message.pFlags.edit_hide) { if(message.edit_date && chatType !== 'scheduled' && !message.pFlags.edit_hide) {
bubble.classList.add('is-edited');
args.unshift(editedSpan = makeEdited()); args.unshift(editedSpan = makeEdited());
} }
if(chat.type !== 'pinned' && message.pFlags.pinned) { if(chatType !== 'pinned' && message.pFlags.pinned) {
bubble.classList.add('is-pinned');
const i = document.createElement('i'); const i = document.createElement('i');
i.classList.add('tgico-pinnedchat', 'time-icon'); i.classList.add('tgico-pinnedchat', 'time-icon');
args.unshift(i); args.unshift(i);
@ -113,8 +111,6 @@ export namespace MessageRender {
timeSpan.append(inner); timeSpan.append(inner);
messageDiv.append(timeSpan);
return timeSpan; return timeSpan;
}; };

Loading…
Cancel
Save