diff --git a/src/components/chat/bubbleGroups.ts b/src/components/chat/bubbleGroups.ts index 1d187a21..a8024520 100644 --- a/src/components/chat/bubbleGroups.ts +++ b/src/components/chat/bubbleGroups.ts @@ -68,14 +68,26 @@ class BubbleGroup { const fwdFromId = message.fwdFromId; const isForwardFromChannel = message.from_id && message.from_id._ === 'peerChannel' && message.fromId === fwdFromId; const currentPeerId = this.chat.peerId; - this.avatar = new AvatarElement(); + const avatar = this.avatar = new AvatarElement(); this.avatar.classList.add('bubbles-group-avatar', 'user-avatar', 'avatar-40'/* , 'can-zoom-fade' */); - this.avatarLoadPromise = this.avatar.updateWithOptions({ + const peerId = ((fwdFrom && (currentPeerId === rootScope.myId || currentPeerId === REPLIES_PEER_ID)) || isForwardFromChannel ? fwdFromId : message.fromId) || NULL_PEER_ID; + const avatarLoadPromise = this.avatar.updateWithOptions({ lazyLoadQueue: this.chat.bubbles.lazyLoadQueue, - peerId: ((fwdFrom && (currentPeerId === rootScope.myId || currentPeerId === REPLIES_PEER_ID)) || isForwardFromChannel ? fwdFromId : message.fromId) || NULL_PEER_ID, + peerId, peerTitle: !fwdFromId && fwdFrom && fwdFrom.from_name ? /* '🔥 FF 🔥' */fwdFrom.from_name : undefined, }); + this.avatarLoadPromise = Promise.all([ + avatarLoadPromise, + peerId && peerId.isUser() ? this.chat.managers.appUsersManager.getUser(peerId.toUserId()) : undefined + ]).then(([result, user]) => { + if(user?.pFlags?.premium) { + avatar.classList.add('is-premium', 'tgico-star'); + } + + return result; + }); + this.avatarContainer.append(this.avatar); this.container.append(this.avatarContainer); diff --git a/src/lib/appManagers/appPeersManager.ts b/src/lib/appManagers/appPeersManager.ts index c44fc865..49f5c214 100644 --- a/src/lib/appManagers/appPeersManager.ts +++ b/src/lib/appManagers/appPeersManager.ts @@ -17,6 +17,7 @@ import { AppManager } from "./manager"; import getPeerId from "./utils/peers/getPeerId"; import isUser from "./utils/peers/isUser"; import isAnyChat from "./utils/peers/isAnyChat"; +import { NULL_PEER_ID } from "../mtproto/mtproto_config"; export type PeerType = 'channel' | 'chat' | 'megagroup' | 'group' | 'saved'; export class AppPeersManager extends AppManager { @@ -87,8 +88,8 @@ export class AppPeersManager extends AppManager { : this.appChatsManager.getChat(peerId.toChatId()); } - public getPeerId(...args: Parameters) { - return getPeerId(...args) || this.peerId; + public getPeerId(peerId: Parameters[0]) { + return getPeerId(peerId) || (isObject(peerId) && peerId._ === 'inputPeerSelf' && this.peerId) || NULL_PEER_ID; } public getDialogPeer(peerId: PeerId): DialogPeer { diff --git a/src/scss/partials/_avatar.scss b/src/scss/partials/_avatar.scss index 9bf59033..d478eb25 100644 --- a/src/scss/partials/_avatar.scss +++ b/src/scss/partials/_avatar.scss @@ -88,6 +88,19 @@ avatar-element { &.media-container { position: relative; } + + &.is-premium { + &:before { + font-size: .6875rem; + color: #fff; + position: absolute; + right: 0; + bottom: -.0625rem; + line-height: 1 !important; + z-index: 1; + pointer-events: none; + } + } img { //width: 100% !important;