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;