Browse Source

Fix splitting peer title

master
Eduard Kuzmenko 3 years ago
parent
commit
207004c889
  1. 2
      src/components/appSelectPeers.ts
  2. 5
      src/components/chat/audio.ts
  3. 10
      src/components/popups/deleteDialog.ts
  4. 5
      src/components/popups/deleteMessages.ts
  5. 2
      src/components/popups/unpinMessage.ts
  6. 2
      src/components/sidebarLeft/index.ts
  7. 5
      src/components/sidebarRight/tabs/sharedMedia.ts
  8. 4
      src/lib/appManagers/appPeersManager.ts
  9. 4
      src/scss/partials/_selector.scss

2
src/components/appSelectPeers.ts

@ -520,7 +520,7 @@ export default class AppSelectPeers {
div.dataset.key = '' + peerId; div.dataset.key = '' + peerId;
if(typeof(peerId) === 'number') { if(typeof(peerId) === 'number') {
if(title === undefined) { if(title === undefined) {
title = new PeerTitle({peerId, onlyFirstName: true, dialog: true}).element; title = new PeerTitle({peerId, dialog: true}).element;
} }
avatarEl.setAttribute('peer', '' + peerId); avatarEl.setAttribute('peer', '' + peerId);

5
src/components/chat/audio.ts

@ -48,10 +48,7 @@ export default class ChatAudio extends PinnedContainer {
let title: string | HTMLElement, subtitle: string; let title: string | HTMLElement, subtitle: string;
const message = appMessagesManager.getMessageByPeer(peerId, mid); const message = appMessagesManager.getMessageByPeer(peerId, mid);
if(doc.type === 'voice' || doc.type === 'round') { if(doc.type === 'voice' || doc.type === 'round') {
title = new PeerTitle({ title = new PeerTitle({peerId: message.fromId}).element;
peerId: message.fromId,
onlyFirstName: true
}).element;
//subtitle = 'Voice message'; //subtitle = 'Voice message';
subtitle = formatDate(message.date, false, false); subtitle = formatDate(message.date, false, false);

10
src/components/popups/deleteDialog.ts

@ -13,10 +13,7 @@ import PopupPeer, { PopupPeerButtonCallbackCheckboxes, PopupPeerOptions } from "
export default class PopupDeleteDialog { export default class PopupDeleteDialog {
constructor(peerId: number, peerType: PeerType = appPeersManager.getDialogType(peerId), onSelect?: (promise: Promise<any>) => void) { constructor(peerId: number, peerType: PeerType = appPeersManager.getDialogType(peerId), onSelect?: (promise: Promise<any>) => void) {
const peerTitleElement = new PeerTitle({ const peerTitleElement = new PeerTitle({peerId}).element;
peerId,
onlyFirstName: true
}).element;
/* const callbackFlush = (checked: PopupPeerButtonCallbackCheckboxes) => { /* const callbackFlush = (checked: PopupPeerButtonCallbackCheckboxes) => {
const promise = appMessagesManager.flushHistory(peerId, checkboxes ? !checked[checkboxes[0].text] : undefined); const promise = appMessagesManager.flushHistory(peerId, checkboxes ? !checked[checkboxes[0].text] : undefined);
@ -86,10 +83,7 @@ export default class PopupDeleteDialog {
checkboxes = [{ checkboxes = [{
text: 'DeleteMessagesOptionAlso', text: 'DeleteMessagesOptionAlso',
textArgs: [ textArgs: [
new PeerTitle({ new PeerTitle({peerId}).element
peerId,
onlyFirstName: true
}).element
] ]
}]; }];

5
src/components/popups/deleteMessages.ts

@ -15,10 +15,7 @@ import PeerTitle from "../peerTitle";
export default class PopupDeleteMessages { export default class PopupDeleteMessages {
constructor(peerId: number, mids: number[], type: ChatType, onConfirm?: () => void) { constructor(peerId: number, mids: number[], type: ChatType, onConfirm?: () => void) {
const peerTitleElement = new PeerTitle({ const peerTitleElement = new PeerTitle({peerId}).element;
peerId,
onlyFirstName: true
}).element;
mids = mids.slice(); mids = mids.slice();
const callback = (checked: PopupPeerButtonCallbackCheckboxes, revoke?: boolean) => { const callback = (checked: PopupPeerButtonCallbackCheckboxes, revoke?: boolean) => {

2
src/components/popups/unpinMessage.ts

@ -97,7 +97,7 @@ export default class PopupPinMessage {
checkboxes.push({ checkboxes.push({
text: 'PinAlsoFor', text: 'PinAlsoFor',
textArgs: [new PeerTitle({peerId, onlyFirstName: true}).element], textArgs: [new PeerTitle({peerId}).element],
checked: true checked: true
}); });
} }

2
src/components/sidebarLeft/index.ts

@ -379,7 +379,7 @@ export class AppSidebarLeft extends SidebarSlider {
div.dataset.key = '' + peerId; div.dataset.key = '' + peerId;
if(typeof(peerId) === 'number') { if(typeof(peerId) === 'number') {
if(title === undefined) { if(title === undefined) {
title = new PeerTitle({peerId, onlyFirstName: true}).element; title = new PeerTitle({peerId}).element;
} }
avatarEl.setAttribute('peer', '' + peerId); avatarEl.setAttribute('peer', '' + peerId);

5
src/components/sidebarRight/tabs/sharedMedia.ts

@ -979,10 +979,7 @@ export default class AppSharedMediaTab extends SliderSuperTab {
if(!isChannel) { if(!isChannel) {
checkboxes = [{ checkboxes = [{
text: 'AddOneMemberForwardMessages', text: 'AddOneMemberForwardMessages',
textArgs: [new PeerTitle({ textArgs: [new PeerTitle({peerId: peerIds[0]}).element],
peerId: peerIds[0],
onlyFirstName: true
}).element],
checked: true checked: true
}]; }];
} }

4
src/lib/appManagers/appPeersManager.ts

@ -87,17 +87,17 @@ export class AppPeersManager {
let title = ''; let title = '';
if(peerId > 0) { if(peerId > 0) {
if(peer.first_name) title += peer.first_name; if(peer.first_name) title += peer.first_name;
if(peer.last_name) title += ' ' + peer.last_name; if(peer.last_name && (!onlyFirstName || !title)) title += ' ' + peer.last_name;
if(!title) title = peer.pFlags.deleted ? I18n.format('HiddenName', true) : peer.username; if(!title) title = peer.pFlags.deleted ? I18n.format('HiddenName', true) : peer.username;
else title = title.trim(); else title = title.trim();
} else { } else {
title = peer.title; title = peer.title;
}
if(onlyFirstName) { if(onlyFirstName) {
title = title.split(' ')[0]; title = title.split(' ')[0];
} }
}
return plainText ? title : RichTextProcessor.wrapEmojiText(title); return plainText ? title : RichTextProcessor.wrapEmojiText(title);
} }

4
src/scss/partials/_selector.scss

@ -56,7 +56,7 @@
background-color: var(--light-secondary-text-color); background-color: var(--light-secondary-text-color);
font-size: 16px; font-size: 16px;
padding: 0 17px 0px 0px; padding: 0 17px 0px 0px;
line-height: 31px; line-height: 1.875rem;
margin-left: -4px; margin-left: -4px;
margin-right: 12px; margin-right: 12px;
height: 32px; height: 32px;
@ -65,7 +65,7 @@
user-select: none; user-select: none;
flex: 0 0 auto; flex: 0 0 auto;
transition: .2s opacity, .2s transform, .2s background-color; transition: .2s opacity, .2s transform, .2s background-color;
max-width: 10rem; max-width: 11.25rem;
@include text-overflow(); @include text-overflow();

Loading…
Cancel
Save