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 { @@ -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<string | number> = 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) {

6
src/lib/appManagers/appPeersManager.ts

@ -51,6 +51,10 @@ export class AppPeersManager { @@ -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 { @@ -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;

Loading…
Cancel
Save