Add premium icon to chat avatar
This commit is contained in:
parent
5758e08291
commit
8262012b48
@ -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);
|
||||
|
||||
|
@ -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<typeof getPeerId>) {
|
||||
return getPeerId(...args) || this.peerId;
|
||||
public getPeerId(peerId: Parameters<typeof getPeerId>[0]) {
|
||||
return getPeerId(peerId) || (isObject<InputPeer>(peerId) && peerId._ === 'inputPeerSelf' && this.peerId) || NULL_PEER_ID;
|
||||
}
|
||||
|
||||
public getDialogPeer(peerId: PeerId): DialogPeer {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user