|
|
@ -33,8 +33,8 @@ import { toast } from "./toast"; |
|
|
|
|
|
|
|
|
|
|
|
let setText = (text: string, row: Row) => { |
|
|
|
let setText = (text: string, row: Row) => { |
|
|
|
//fastRaf(() => {
|
|
|
|
//fastRaf(() => {
|
|
|
|
row.title.innerHTML = text; |
|
|
|
row.title.innerHTML = text || ''; |
|
|
|
row.container.style.display = ''; |
|
|
|
row.container.style.display = text ? '' : 'none'; |
|
|
|
//});
|
|
|
|
//});
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -207,6 +207,12 @@ export default class PeerProfile { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listenerSetter.add(rootScope)('peer_title_edit', (peerId) => { |
|
|
|
|
|
|
|
if(peerId === this.peerId) { |
|
|
|
|
|
|
|
this.fillUsername(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
listenerSetter.add(rootScope)('user_update', (userId) => { |
|
|
|
listenerSetter.add(rootScope)('user_update', (userId) => { |
|
|
|
if(this.peerId === userId.toPeerId()) { |
|
|
|
if(this.peerId === userId.toPeerId()) { |
|
|
|
this.setPeerStatus(); |
|
|
|
this.setPeerStatus(); |
|
|
@ -216,12 +222,8 @@ export default class PeerProfile { |
|
|
|
listenerSetter.add(rootScope)('contacts_update', (userId) => { |
|
|
|
listenerSetter.add(rootScope)('contacts_update', (userId) => { |
|
|
|
if(this.peerId === userId.toPeerId()) { |
|
|
|
if(this.peerId === userId.toPeerId()) { |
|
|
|
const user = appUsersManager.getUser(userId); |
|
|
|
const user = appUsersManager.getUser(userId); |
|
|
|
if(!user.pFlags.self) { |
|
|
|
if(!user.pFlags.self || !this.isDialog) { |
|
|
|
if(user.phone) { |
|
|
|
this.fillUserPhone(); |
|
|
|
setText(appUsersManager.formatUserPhone(user.phone), this.phone); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.phone.container.style.display = 'none'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -299,47 +301,44 @@ export default class PeerProfile { |
|
|
|
this.section.content.prepend(this.avatar, this.name, this.subtitle); |
|
|
|
this.section.content.prepend(this.avatar, this.name, this.subtitle); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public fillProfileElements() { |
|
|
|
private fillUsername() { |
|
|
|
if(!this.cleaned) return; |
|
|
|
const {peerId} = this; |
|
|
|
this.cleaned = false; |
|
|
|
if(peerId.isUser() && this.canBeDetailed()) { |
|
|
|
|
|
|
|
const username = appPeersManager.getPeerUsername(peerId); |
|
|
|
const peerId = this.peerId; |
|
|
|
setText(username, this.username); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.cleanupHTML(); |
|
|
|
private fillUserPhone() { |
|
|
|
|
|
|
|
const {peerId} = this; |
|
|
|
|
|
|
|
if(peerId.isUser() && this.canBeDetailed()) { |
|
|
|
|
|
|
|
const user = appUsersManager.getUser(peerId); |
|
|
|
|
|
|
|
setText(user.phone ? appUsersManager.formatUserPhone(user.phone) : undefined, this.phone); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.setAvatar(); |
|
|
|
private fillNotifications() { |
|
|
|
|
|
|
|
const notificationsRow = this.notifications; |
|
|
|
|
|
|
|
if(!notificationsRow) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// username
|
|
|
|
|
|
|
|
if(this.canBeDetailed()) { |
|
|
|
if(this.canBeDetailed()) { |
|
|
|
if(peerId.isUser()) { |
|
|
|
const muted = appNotificationsManager.isPeerLocalMuted(this.peerId, false); |
|
|
|
const username = appPeersManager.getPeerUsername(peerId); |
|
|
|
notificationsRow.checkboxField.checked = !muted; |
|
|
|
if(username) { |
|
|
|
} else { |
|
|
|
setText(appPeersManager.getPeerUsername(peerId), this.username); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.notifications) { |
|
|
|
|
|
|
|
const muted = appNotificationsManager.isPeerLocalMuted(peerId, false); |
|
|
|
|
|
|
|
this.notifications.checkboxField.checked = !muted; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if(this.notifications) { |
|
|
|
|
|
|
|
fastRaf(() => { |
|
|
|
fastRaf(() => { |
|
|
|
this.notifications.container.style.display = 'none'; |
|
|
|
notificationsRow.container.style.display = 'none'; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//let membersLi = this.profileTabs.firstElementChild.children[0] as HTMLLIElement;
|
|
|
|
private fillRows() { |
|
|
|
if(peerId.isUser()) { |
|
|
|
const peerId = this.peerId; |
|
|
|
//membersLi.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let user = appUsersManager.getUser(peerId); |
|
|
|
|
|
|
|
if(user.phone && this.canBeDetailed()) { |
|
|
|
|
|
|
|
setText(appUsersManager.formatUserPhone(user.phone), this.phone); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}/* else { |
|
|
|
|
|
|
|
//membersLi.style.display = appPeersManager.isBroadcast(peerId) ? 'none' : '';
|
|
|
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.fillUsername(); |
|
|
|
|
|
|
|
this.fillUserPhone(); |
|
|
|
|
|
|
|
this.fillNotifications(); |
|
|
|
this.setMoreDetails(); |
|
|
|
this.setMoreDetails(); |
|
|
|
|
|
|
|
|
|
|
|
replaceContent(this.name, new PeerTitle({ |
|
|
|
replaceContent(this.name, new PeerTitle({ |
|
|
@ -355,6 +354,15 @@ export default class PeerProfile { |
|
|
|
this.setPeerStatus(true); |
|
|
|
this.setPeerStatus(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public fillProfileElements() { |
|
|
|
|
|
|
|
if(!this.cleaned) return; |
|
|
|
|
|
|
|
this.cleaned = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.cleanupHTML(); |
|
|
|
|
|
|
|
this.setAvatar(); |
|
|
|
|
|
|
|
this.fillRows(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public setMoreDetails(override?: true) { |
|
|
|
public setMoreDetails(override?: true) { |
|
|
|
if(this.setMoreDetailsTimeout) { |
|
|
|
if(this.setMoreDetailsTimeout) { |
|
|
|
window.clearTimeout(this.setMoreDetailsTimeout); |
|
|
|
window.clearTimeout(this.setMoreDetailsTimeout); |
|
|
@ -376,9 +384,9 @@ export default class PeerProfile { |
|
|
|
|
|
|
|
|
|
|
|
//this.log('chatInfo res 2:', chatFull);
|
|
|
|
//this.log('chatInfo res 2:', chatFull);
|
|
|
|
|
|
|
|
|
|
|
|
if(peerFull.about) { |
|
|
|
// if(peerFull.about) {
|
|
|
|
setText(RichTextProcessor.wrapRichText(peerFull.about), this.bio); |
|
|
|
setText(peerFull.about ? RichTextProcessor.wrapRichText(peerFull.about) : undefined, this.bio); |
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if(!peerId.isUser()) { |
|
|
|
if(!peerId.isUser()) { |
|
|
|
const chat: Chat.channel = appChatsManager.getChat(peerId.toChatId()); |
|
|
|
const chat: Chat.channel = appChatsManager.getChat(peerId.toChatId()); |
|
|
|