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 { @@ -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');

20
src/components/chat/messageRender.ts

@ -12,7 +12,7 @@ import RichTextProcessor from "../../lib/richtextprocessor"; @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -113,8 +111,6 @@ export namespace MessageRender {
timeSpan.append(inner);
messageDiv.append(timeSpan);
return timeSpan;
};

Loading…
Cancel
Save