From 1d6ec6f630f439863691f50473553f8c280b48b2 Mon Sep 17 00:00:00 2001 From: Eduard Kuzmenko Date: Tue, 8 Feb 2022 23:32:02 +0400 Subject: [PATCH] Reactions: support 138 layer --- src/components/chat/contextMenu.ts | 2 +- src/components/chat/reaction.ts | 7 ++++--- src/lib/appManagers/appMessagesManager.ts | 12 ++++++------ src/lib/appManagers/appReactionsManager.ts | 12 ++++++------ src/scss/partials/_fonts.scss | 6 +++--- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/components/chat/contextMenu.ts b/src/components/chat/contextMenu.ts index 9ed8eb5f..9852498d 100644 --- a/src/components/chat/contextMenu.ts +++ b/src/components/chat/contextMenu.ts @@ -809,7 +809,7 @@ export default class ChatContextMenu { if(reactions.length) { const avatars = new StackedAvatars({avatarSize: 24}); - avatars.render(recentReactions ? recentReactions.map(r => r.user_id.toPeerId()) : reactions.map(reaction => reaction.peerId)); + avatars.render(recentReactions ? recentReactions.map(r => this.appPeersManager.getPeerId(r.peer_id)) : reactions.map(reaction => reaction.peerId)); viewsButton.element.append(avatars.container); // if(reactions.length > 1) { diff --git a/src/components/chat/reaction.ts b/src/components/chat/reaction.ts index a0e6dcf4..8f9a110e 100644 --- a/src/components/chat/reaction.ts +++ b/src/components/chat/reaction.ts @@ -6,7 +6,8 @@ import callbackify from "../../helpers/callbackify"; import { formatNumber } from "../../helpers/number"; -import { MessageUserReaction, ReactionCount } from "../../layer"; +import { MessagePeerReaction, ReactionCount } from "../../layer"; +import appPeersManager from "../../lib/appManagers/appPeersManager"; import appReactionsManager from "../../lib/appManagers/appReactionsManager"; import RLottiePlayer from "../../lib/rlottie/rlottiePlayer"; import SetTransition from "../singleTransition"; @@ -103,7 +104,7 @@ export default class ReactionElement extends HTMLElement { } } - public renderAvatars(recentReactions: MessageUserReaction[]) { + public renderAvatars(recentReactions: MessagePeerReaction[]) { if(this.type === 'inline') { return; } @@ -125,7 +126,7 @@ export default class ReactionElement extends HTMLElement { this.append(this.stackedAvatars.container); } - this.stackedAvatars.render(recentReactions.map(reaction => reaction.user_id.toPeerId())); + this.stackedAvatars.render(recentReactions.map(reaction => appPeersManager.getPeerId(reaction.peer_id))); } public setIsChosen(isChosen = !!this.reactionCount.pFlags.chosen) { diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 8041924b..45f3c49f 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -17,7 +17,7 @@ import { createPosterForVideo } from "../../helpers/files"; import { copy, deepEqual, getObjectKeysAndSort } from "../../helpers/object"; import { randomLong } from "../../helpers/random"; import { splitStringByLength, limitSymbols, escapeRegExp } from "../../helpers/string"; -import { Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update, Photo, Updates, ReplyMarkup, InputPeer, InputPhoto, InputDocument, InputGeoPoint, WebPage, GeoPoint, ReportReason, MessagesGetDialogs, InputChannel, InputDialogPeer, MessageUserReaction, ReactionCount } from "../../layer"; +import { Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageMedia, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update, Photo, Updates, ReplyMarkup, InputPeer, InputPhoto, InputDocument, InputGeoPoint, WebPage, GeoPoint, ReportReason, MessagesGetDialogs, InputChannel, InputDialogPeer, ReactionCount, MessagePeerReaction } from "../../layer"; import { InvokeApiOptions } from "../../types"; import I18n, { FormatterArguments, i18n, join, langPack, LangPackKey, UNSUPPORTED_LANG_PACK_KEY, _i18n } from "../langPack"; import { logger, LogTypes } from "../logger"; @@ -4613,7 +4613,7 @@ export class AppMessagesManager { const previousReactions = message.reactions; const previousRecentReactions = previousReactions?.recent_reactions; if( - recentReaction.user_id !== rootScope.myId.toUserId() && ( + appPeersManager.getPeerId(recentReaction.peer_id) !== rootScope.myId && ( !previousRecentReactions || previousRecentReactions.length <= recentReactions.length ) && ( @@ -5383,7 +5383,7 @@ export class AppMessagesManager { skipReactionsList?: boolean ) { const emptyMessageReactionsList = { - reactions: [] as MessageUserReaction[], + reactions: [] as MessagePeerReaction[], count: 0, next_offset: undefined as string }; @@ -5404,12 +5404,12 @@ export class AppMessagesManager { const filteredReadParticipants = readParticipantsPeerIds.slice(); forEachReverse(filteredReadParticipants, (peerId, idx, arr) => { - if(messageReactionsList.reactions.some(reaction => reaction.user_id.toPeerId() === peerId)) { + if(messageReactionsList.reactions.some(reaction => appPeersManager.getPeerId(reaction.peer_id) === peerId)) { arr.splice(idx, 1); } }); - let combined: {peerId: PeerId, reaction?: string}[] = messageReactionsList.reactions.map(reaction => ({peerId: reaction.user_id.toPeerId(), reaction: reaction.reaction})); + let combined: {peerId: PeerId, reaction?: string}[] = messageReactionsList.reactions.map(reaction => ({peerId: appPeersManager.getPeerId(reaction.peer_id), reaction: reaction.reaction})); combined = combined.concat(filteredReadParticipants.map(readPeerId => ({peerId: readPeerId}))); return { @@ -5478,7 +5478,7 @@ export class AppMessagesManager { private notifyAboutMessage(message: MyMessage, options: Partial<{ fwdCount: number, - userReaction: MessageUserReaction, + userReaction: MessagePeerReaction, peerTypeNotifySettings: PeerNotifySettings }> = {}) { const peerId = this.getMessagePeer(message); diff --git a/src/lib/appManagers/appReactionsManager.ts b/src/lib/appManagers/appReactionsManager.ts index 8cc4f267..cf458ad2 100644 --- a/src/lib/appManagers/appReactionsManager.ts +++ b/src/lib/appManagers/appReactionsManager.ts @@ -9,7 +9,7 @@ import assumeType from "../../helpers/assumeType"; import callbackify from "../../helpers/callbackify"; import callbackifyAll from "../../helpers/callbackifyAll"; import { copy } from "../../helpers/object"; -import { AvailableReaction, Message, MessagesAvailableReactions, MessageUserReaction, Update, Updates } from "../../layer"; +import { AvailableReaction, Message, MessagePeerReaction, MessagesAvailableReactions, Update, Updates } from "../../layer"; import apiManager from "../mtproto/mtprotoworker"; import { ReferenceContext } from "../mtproto/referenceDatabase"; import rootScope from "../rootScope"; @@ -225,7 +225,7 @@ export class AppReactionsManager { } const {peerId, mid} = message; - const myUserId = rootScope.myId.toUserId(); + const myPeerId = rootScope.myId; let reactions = onlyLocal ? message.reactions : copy(message.reactions); let chosenReactionIdx = reactions ? reactions.results.findIndex((reactionCount) => reactionCount.pFlags.chosen) : -1; @@ -245,7 +245,7 @@ export class AppReactionsManager { } */ if(reactions.recent_reactions) { - reactions.recent_reactions.findAndSplice((recentReaction) => recentReaction.user_id === myUserId); + reactions.recent_reactions.findAndSplice((recentReaction) => appPeersManager.getPeerId(recentReaction.peer_id) === myPeerId); } if(!reactions.results.length) { @@ -287,10 +287,10 @@ export class AppReactionsManager { } if(reactions.recent_reactions) { - const userReaction: MessageUserReaction = { - _: 'messageUserReaction', + const userReaction: MessagePeerReaction = { + _: 'messagePeerReaction', reaction, - user_id: myUserId + peer_id: appPeersManager.getOutputPeer(myPeerId) }; if(!appPeersManager.isMegagroup(peerId)) { diff --git a/src/scss/partials/_fonts.scss b/src/scss/partials/_fonts.scss index 0179b645..a5122103 100644 --- a/src/scss/partials/_fonts.scss +++ b/src/scss/partials/_fonts.scss @@ -9,9 +9,9 @@ @font-face { font-family: "#{$tgico-font-family}"; src: - url('#{$tgico-font-path}/#{$tgico-font-family}.ttf?yaqhmr') format('truetype'), - url('#{$tgico-font-path}/#{$tgico-font-family}.woff?yaqhmr') format('woff'), - url('#{$tgico-font-path}/#{$tgico-font-family}.svg?yaqhmr#tgico') format('svg'); + url('#{$tgico-font-path}/#{$tgico-font-family}.ttf?xxkozq') format('truetype'), + url('#{$tgico-font-path}/#{$tgico-font-family}.woff?xxkozq') format('woff'), + url('#{$tgico-font-path}/#{$tgico-font-family}.svg?xxkozq#tgico') format('svg'); font-weight: normal; font-style: normal; font-display: block;