From ded66cf09be84932fafec06204109971097d5dce Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Thu, 24 Dec 2020 09:37:12 +0200 Subject: [PATCH] Change helper subtitle for forwarding & editing --- src/components/chat/input.ts | 21 +++++++++++++----- src/lib/appManagers/appMessagesManager.ts | 27 ++++++++++++++++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/components/chat/input.ts b/src/components/chat/input.ts index 3d7c4b78..4df48543 100644 --- a/src/components/chat/input.ts +++ b/src/components/chat/input.ts @@ -1193,7 +1193,12 @@ export default class ChatInput { let input = RichTextProcessor.wrapDraftText(message.message, {entities: message.totalEntities}); const f = () => { - this.setTopInfo('edit', f, 'Editing', message.message, input, message); + // ! костыль + const replyText = this.appMessagesManager.getRichReplyText(message, undefined, [message.mid]); + this.setTopInfo('edit', f, 'Editing', undefined, input, message); + const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle'); + subtitleEl.innerHTML = replyText; + this.editMsgId = mid; input = undefined; }; @@ -1220,11 +1225,17 @@ export default class ChatInput { }); const title = peerTitles.length < 3 ? peerTitles.join(' and ') : peerTitles[0] + ' and ' + (peerTitles.length - 1) + ' others'; - if(mids.length == 1) { - const message = this.appMessagesManager.getMessageByPeer(fromPeerId, mids[0]); - this.setTopInfo('forward', f, title, message.message, undefined, message); + const firstMessage = this.appMessagesManager.getMessageByPeer(fromPeerId, mids[0]); + + const replyText = this.appMessagesManager.getRichReplyText(firstMessage, undefined, mids); + if(replyText.includes('Album') || mids.length === 1) { + this.setTopInfo('forward', f, title); + + // ! костыль + const subtitleEl = this.replyElements.container.querySelector('.reply-subtitle'); + subtitleEl.innerHTML = replyText; } else { - this.setTopInfo('forward', f, title, mids.length + ' forwarded messages'); + this.setTopInfo('forward', f, title, mids.length + ' ' + (mids.length > 1 ? 'forwarded messages' : 'forwarded message')); } this.forwardingMids = mids.slice(); diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 6d35314e..d4f9faee 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -2298,14 +2298,35 @@ export class AppMessagesManager { } } - public getRichReplyText(message: any, text: string = message.message) { + public getRichReplyText(message: any, text: string = message.message, usingMids?: number[]) { let messageText = ''; if(message.media) { + let usingFullAlbum = true; if(message.grouped_id) { - text = this.getAlbumText(message.grouped_id).message; - messageText += 'Album' + (text ? ', ' : '') + ''; + if(usingMids) { + const mids = this.getMidsByMessage(message); + if(usingMids.length === mids.length) { + for(const mid of mids) { + if(!usingMids.includes(mid)) { + usingFullAlbum = false; + break; + } + } + } else { + usingFullAlbum = false; + } + } + + if(usingFullAlbum) { + text = this.getAlbumText(message.grouped_id).message; + messageText += 'Album' + (text ? ', ' : '') + ''; + } } else { + usingFullAlbum = false; + } + + if(!usingFullAlbum) { const media = message.media; switch(media._) { case 'messageMediaPhoto':