Browse Source

Fix forward messages from hidden profiles

Fix reply hidden profile title
master
morethanwords 4 years ago
parent
commit
0184d89a48
  1. 18
      src/components/chat/input.ts
  2. 6
      src/lib/appManagers/appPeersManager.ts

18
src/components/chat/input.ts

@ -649,9 +649,21 @@ export class ChatInput {
public initMessagesForward(mids: number[]) { public initMessagesForward(mids: number[]) {
const f = () => { const f = () => {
//const peerTitles: string[] //const peerTitles: string[]
const fromIDs = new Set(mids.map(mid => appMessagesManager.getMessage(mid).fromID)); const smth: Set<string | number> = new Set(mids.map(mid => {
const onlyFirstName = fromIDs.size > 1; const message = appMessagesManager.getMessage(mid);
const peerTitles = [...fromIDs].map(peerID => appPeersManager.getPeerTitle(peerID, true, onlyFirstName)); 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'; const title = peerTitles.length < 3 ? peerTitles.join(' and ') : peerTitles[0] + ' and ' + (peerTitles.length - 1) + ' others';
if(mids.length == 1) { if(mids.length == 1) {

6
src/lib/appManagers/appPeersManager.ts

@ -51,6 +51,10 @@ export class AppPeersManager {
} }
public getPeerTitle(peerID: number | any, plainText = false, onlyFirstName = false) { public getPeerTitle(peerID: number | any, plainText = false, onlyFirstName = false) {
if(!peerID) {
peerID = $rootScope.myID;
}
let peer: any = {}; let peer: any = {};
if(!isObject(peerID)) { if(!isObject(peerID)) {
peer = this.getPeer(peerID); peer = this.getPeer(peerID);
@ -206,6 +210,8 @@ export class AppPeersManager {
} }
public getPeerColorByID(peerID: number, pic = true) { public getPeerColorByID(peerID: number, pic = true) {
if(!peerID) return '';
const idx = DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7]; const idx = DialogColorsMap[(peerID < 0 ? -peerID : peerID) % 7];
const color = (pic ? DialogColors : DialogColorsFg)[idx]; const color = (pic ? DialogColors : DialogColorsFg)[idx];
return color; return color;

Loading…
Cancel
Save