Browse Source

Display chat link instead of username

master
Eduard Kuzmenko 3 years ago
parent
commit
97c368bf1d
  1. 22
      src/components/peerProfile.ts

22
src/components/peerProfile.ts

@ -10,8 +10,8 @@ import { copyTextToClipboard } from "../helpers/clipboard";
import replaceContent from "../helpers/dom/replaceContent"; import replaceContent from "../helpers/dom/replaceContent";
import ListenerSetter from "../helpers/listenerSetter"; import ListenerSetter from "../helpers/listenerSetter";
import { fastRaf } from "../helpers/schedulers"; import { fastRaf } from "../helpers/schedulers";
import { ChatFull, User } from "../layer"; import { Chat, ChatFull, User } from "../layer";
import { Channel } from "../lib/appManagers/appChatsManager"; import appChatsManager, { Channel } from "../lib/appManagers/appChatsManager";
import appImManager from "../lib/appManagers/appImManager"; import appImManager from "../lib/appManagers/appImManager";
import appMessagesManager from "../lib/appManagers/appMessagesManager"; import appMessagesManager from "../lib/appManagers/appMessagesManager";
import appNotificationsManager from "../lib/appManagers/appNotificationsManager"; import appNotificationsManager from "../lib/appManagers/appNotificationsManager";
@ -140,10 +140,11 @@ export default class PeerProfile {
subtitleLangKey: 'SetUrlPlaceholder', subtitleLangKey: 'SetUrlPlaceholder',
icon: 'link', icon: 'link',
clickable: () => { clickable: () => {
Promise.resolve(appProfileManager.getChatFull(this.peerId.toChatId())).then(chatFull => { copyTextToClipboard(this.link.title.textContent);
copyTextToClipboard(chatFull.exported_invite.link); // Promise.resolve(appProfileManager.getChatFull(this.peerId.toChatId())).then(chatFull => {
// copyTextToClipboard(chatFull.exported_invite.link);
toast(I18n.format('LinkCopied', true)); toast(I18n.format('LinkCopied', true));
}); // });
} }
}); });
@ -310,10 +311,12 @@ export default class PeerProfile {
// username // username
if(this.canBeDetailed()) { if(this.canBeDetailed()) {
let username = appPeersManager.getPeerUsername(peerId); if(peerId.isUser()) {
const username = appPeersManager.getPeerUsername(peerId);
if(username) { if(username) {
setText(appPeersManager.getPeerUsername(peerId), this.username); setText(appPeersManager.getPeerUsername(peerId), this.username);
} }
}
if(this.notifications) { if(this.notifications) {
const muted = appNotificationsManager.isPeerLocalMuted(peerId, false); const muted = appNotificationsManager.isPeerLocalMuted(peerId, false);
@ -377,10 +380,17 @@ export default class PeerProfile {
setText(RichTextProcessor.wrapRichText(peerFull.about), this.bio); setText(RichTextProcessor.wrapRichText(peerFull.about), this.bio);
} }
if(!peerId.isUser()) {
const chat: Chat.channel = appChatsManager.getChat(peerId.toChatId());
if(chat.username) {
setText('https://t.me/' + chat.username, this.link);
} else {
const exportedInvite = (peerFull as ChatFull.channelFull).exported_invite; const exportedInvite = (peerFull as ChatFull.channelFull).exported_invite;
if(exportedInvite) { if(exportedInvite) {
setText(exportedInvite.link, this.link); setText(exportedInvite.link, this.link);
} }
}
}
const location = (peerFull as ChatFull.channelFull).location; const location = (peerFull as ChatFull.channelFull).location;
if(location?._ == 'channelLocation') { if(location?._ == 'channelLocation') {

Loading…
Cancel
Save