From caa14dc6239d6a62b3ce388591d379a047adb19b Mon Sep 17 00:00:00 2001 From: morethanwords Date: Thu, 12 Aug 2021 09:06:10 +0300 Subject: [PATCH] Draft: load missing replying message --- src/components/chat/input.ts | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/chat/input.ts b/src/components/chat/input.ts index ac0af32b..55205487 100644 --- a/src/components/chat/input.ts +++ b/src/components/chat/input.ts @@ -32,7 +32,7 @@ import PopupNewMedia from '../popups/newMedia'; import { toast } from "../toast"; import { wrapReply } from "../wrappers"; import InputField from '../inputField'; -import { MessageEntity, DraftMessage, WebPage } from '../../layer'; +import { MessageEntity, DraftMessage, WebPage, Message } from '../../layer'; import StickersHelper from './stickersHelper'; import ButtonIcon from '../buttonIcon'; import ButtonMenuToggle from '../buttonMenuToggle'; @@ -1768,13 +1768,32 @@ export default class ChatInput { } public initMessageReply(mid: number) { - const message = this.chat.getMessage(mid); + let message: Message = this.chat.getMessage(mid); const f = () => { - const peerTitleEl = new PeerTitle({ - peerId: message.fromId, - dialog: false - }).element; - this.setTopInfo('reply', f, peerTitleEl, message.message, undefined, message); + let peerTitleEl: HTMLElement; + if(message._ === 'messageEmpty') { // load missing replying message + peerTitleEl = i18n('Loading'); + + this.chat.appMessagesManager.wrapSingleMessage(this.chat.peerId, mid).then(() => { + if(this.replyToMsgId !== mid) { + return; + } + + message = this.chat.getMessage(mid); + if(message._ === 'messageEmpty') { + this.clearHelper('reply'); + } else { + f(); + } + }); + } else { + peerTitleEl = new PeerTitle({ + peerId: message.fromId, + dialog: false + }).element; + } + + this.setTopInfo('reply', f, peerTitleEl, message && (message as Message.message).message, undefined, message); this.replyToMsgId = mid; }; f();