From 0184d89a4863c95ac32cd4c2ddc080d5b1f0a7db Mon Sep 17 00:00:00 2001 From: morethanwords Date: Thu, 5 Nov 2020 18:48:14 +0200 Subject: [PATCH] Fix forward messages from hidden profiles Fix reply hidden profile title --- src/components/chat/input.ts | 18 +++++++++++++++--- src/lib/appManagers/appPeersManager.ts | 6 ++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/chat/input.ts b/src/components/chat/input.ts index 999b3775..baafa896 100644 --- a/src/components/chat/input.ts +++ b/src/components/chat/input.ts @@ -649,9 +649,21 @@ export class ChatInput { public initMessagesForward(mids: number[]) { const f = () => { //const peerTitles: string[] - const fromIDs = new Set(mids.map(mid => appMessagesManager.getMessage(mid).fromID)); - const onlyFirstName = fromIDs.size > 1; - const peerTitles = [...fromIDs].map(peerID => appPeersManager.getPeerTitle(peerID, true, onlyFirstName)); + const smth: Set = new Set(mids.map(mid => { + const message = appMessagesManager.getMessage(mid); + if(message.fwd_from && message.fwd_from.from_name && !message.fromID && !message.fwdFromID) { + return message.fwd_from.from_name; + } else { + return message.fromID; + } + })); + + const onlyFirstName = smth.size > 1; + const peerTitles = [...smth].map(smth => { + return typeof(smth) === 'number' ? + appPeersManager.getPeerTitle(smth, true, onlyFirstName) : + (onlyFirstName ? smth.split(' ')[0] : smth); + }); const title = peerTitles.length < 3 ? peerTitles.join(' and ') : peerTitles[0] + ' and ' + (peerTitles.length - 1) + ' others'; if(mids.length == 1) { diff --git a/src/lib/appManagers/appPeersManager.ts b/src/lib/appManagers/appPeersManager.ts index 2664a43e..7b9352d3 100644 --- a/src/lib/appManagers/appPeersManager.ts +++ b/src/lib/appManagers/appPeersManager.ts @@ -51,6 +51,10 @@ export class AppPeersManager { } public getPeerTitle(peerID: number | any, plainText = false, onlyFirstName = false) { + if(!peerID) { + peerID = $rootScope.myID; + } + let peer: any = {}; if(!isObject(peerID)) { peer = this.getPeer(peerID); @@ -206,6 +210,8 @@ export class AppPeersManager { } public getPeerColorByID(peerID: number, pic = true) { + if(!peerID) return ''; + const idx = DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7]; const color = (pic ? DialogColors : DialogColorsFg)[idx]; return color;