diff --git a/src/api/gramjs/apiBuilders/messages.ts b/src/api/gramjs/apiBuilders/messages.ts index 48a5f85d7..21565d6ca 100644 --- a/src/api/gramjs/apiBuilders/messages.ts +++ b/src/api/gramjs/apiBuilders/messages.ts @@ -217,7 +217,7 @@ export function buildApiMessageWithChatId( ...(keyboardButtons && { keyboardButtons, keyboardPlaceholder, isKeyboardSingleUse }), ...(shouldHideKeyboardButtons && { shouldHideKeyboardButtons }), ...(mtpMessage.viaBotId && { viaBotId: buildApiPeerId(mtpMessage.viaBotId, 'user') }), - ...(replies?.comments && { threadInfo: buildThreadInfo(replies, mtpMessage.id, chatId) }), + ...(replies?.comments && { repliesThreadInfo: buildThreadInfo(replies, mtpMessage.id, chatId) }), ...(postAuthor && { postAuthorTitle: postAuthor }), isProtected, isForwardingAllowed, diff --git a/src/api/gramjs/methods/messages.ts b/src/api/gramjs/methods/messages.ts index 2e426f13b..a51416c3e 100644 --- a/src/api/gramjs/methods/messages.ts +++ b/src/api/gramjs/methods/messages.ts @@ -126,13 +126,13 @@ export async function fetchMessages({ const messages = result.messages.map(buildApiMessage).filter(Boolean); const users = result.users.map(buildApiUser).filter(Boolean); const chats = result.chats.map((c) => buildApiChatFromPreview(c)).filter(Boolean); - const threadInfos = messages.map(({ threadInfo }) => threadInfo).filter(Boolean); + const repliesThreadInfos = messages.map(({ repliesThreadInfo }) => repliesThreadInfo).filter(Boolean); return { messages, users, chats, - threadInfos, + repliesThreadInfos, }; } diff --git a/src/api/types/messages.ts b/src/api/types/messages.ts index ba689a7a4..493489244 100644 --- a/src/api/types/messages.ts +++ b/src/api/types/messages.ts @@ -409,7 +409,7 @@ export interface ApiMessage { keyboardPlaceholder?: string; isKeyboardSingleUse?: boolean; viaBotId?: string; - threadInfo?: ApiThreadInfo; + repliesThreadInfo?: ApiThreadInfo; postAuthorTitle?: string; isScheduled?: boolean; shouldHideKeyboardButtons?: boolean; diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index 261aa0f0c..2a0f6c5cb 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -216,7 +216,7 @@ type StateProps = { canAutoPlayMedia?: boolean; shouldLoopStickers?: boolean; autoLoadFileMaxSizeMb: number; - threadInfo?: ApiThreadInfo; + repliesThreadInfo?: ApiThreadInfo; reactionMessage?: ApiMessage; availableReactions?: ApiAvailableReaction[]; defaultReaction?: ApiReaction; @@ -318,7 +318,7 @@ const Message: FC = ({ canAutoPlayMedia, shouldLoopStickers, autoLoadFileMaxSizeMb, - threadInfo, + repliesThreadInfo, hasUnreadReaction, memoFirstUnreadIdRef, animationLevel, @@ -379,7 +379,7 @@ const Message: FC = ({ const isOwn = isOwnMessage(message); const isScheduled = messageListType === 'scheduled' || message.isScheduled; const hasReply = isReplyMessage(message) && !shouldHideReply; - const hasThread = Boolean(threadInfo) && messageListType === 'thread'; + const hasThread = Boolean(repliesThreadInfo) && messageListType === 'thread'; const isCustomShape = getMessageCustomShape(message); const hasAnimatedEmoji = isCustomShape && (animatedEmoji || animatedCustomEmoji); const hasReactions = reactionMessage?.reactions && !areReactionsEmpty(reactionMessage.reactions); @@ -531,7 +531,8 @@ const Message: FC = ({ const { phoneCall } = action || {}; - const withCommentButton = threadInfo && !isInDocumentGroupNotLast && messageListType === 'thread' && !noComments; + const withCommentButton = repliesThreadInfo && !isInDocumentGroupNotLast && messageListType === 'thread' + && !noComments; const withQuickReactionButton = !IS_TOUCH_ENV && !phoneCall && !isInSelectMode && defaultReaction && !isInDocumentGroupNotLast; @@ -542,7 +543,7 @@ const Message: FC = ({ asForwarded, hasThread, forceSenderName, - hasComments: threadInfo && threadInfo?.messagesCount > 0, + hasComments: repliesThreadInfo && repliesThreadInfo.messagesCount > 0, hasActionButton: canForward || canFocus, hasReactions, isGeoLiveActive: location?.type === 'geoLive' && !isGeoLiveExpired(message, getServerTime(serverTimeOffset)), @@ -1122,7 +1123,7 @@ const Message: FC = ({ ) : undefined} - {withCommentButton && } + {withCommentButton && } {withAppendix && (
)} @@ -1179,7 +1180,8 @@ export default memo(withGlobal( message, album, withSenderName, withAvatar, threadId, messageListType, isLastInDocumentGroup, isFirstInGroup, } = ownProps; const { - id, chatId, viaBotId, replyToChatId, replyToMessageId, isOutgoing, threadInfo, forwardInfo, transcriptionId, + id, chatId, viaBotId, replyToChatId, replyToMessageId, isOutgoing, repliesThreadInfo, forwardInfo, + transcriptionId, } = message; const chat = selectChat(global, chatId); @@ -1237,8 +1239,8 @@ export default memo(withGlobal( const { canReply } = (messageListType === 'thread' && selectAllowedMessageActions(global, message, threadId)) || {}; const isDownloading = selectIsDownloading(global, message); - const actualThreadInfo = threadInfo - ? selectThreadInfo(global, threadInfo.chatId, threadInfo.threadId) || threadInfo + const actualRepliesThreadInfo = repliesThreadInfo + ? selectThreadInfo(global, repliesThreadInfo.chatId, repliesThreadInfo.threadId) || repliesThreadInfo : undefined; const isInDocumentGroup = Boolean(message.groupedId) && !message.isInAlbum; @@ -1296,7 +1298,7 @@ export default memo(withGlobal( canAutoPlayMedia: selectCanAutoPlayMedia(global, message), autoLoadFileMaxSizeMb: global.settings.byKey.autoLoadFileMaxSizeMb, shouldLoopStickers: selectShouldLoopStickers(global), - threadInfo: actualThreadInfo, + repliesThreadInfo: actualRepliesThreadInfo, availableReactions: global.availableReactions, defaultReaction: isMessageLocal(message) ? undefined : selectDefaultReaction(global, chatId), activeReactions: reactionMessage && global.activeReactions[reactionMessage.id], diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index cd914f680..cdadb0321 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -113,10 +113,10 @@ addActionHandler('openChat', (global, actions, payload) => { } // Please telegram send us some updates about linked chat 🙏 - if (chat?.lastMessage?.threadInfo) { + if (chat?.lastMessage?.repliesThreadInfo) { actions.requestThreadInfoUpdate({ - chatId: chat.lastMessage.threadInfo.chatId, - threadId: chat.lastMessage.threadInfo.threadId, + chatId: chat.lastMessage.repliesThreadInfo.chatId, + threadId: chat.lastMessage.repliesThreadInfo.threadId, }); } diff --git a/src/global/actions/api/messages.ts b/src/global/actions/api/messages.ts index dc5e21048..9c7f65b64 100644 --- a/src/global/actions/api/messages.ts +++ b/src/global/actions/api/messages.ts @@ -851,7 +851,7 @@ async function loadViewportMessages( } const { - messages, users, chats, threadInfos, + messages, users, chats, repliesThreadInfos, } = result; let global = getGlobal(); @@ -870,7 +870,7 @@ async function loadViewportMessages( global = addUsers(global, buildCollectionByKey(users, 'id')); global = addChats(global, buildCollectionByKey(chats, 'id')); - global = updateThreadInfos(global, chatId, threadInfos); + global = updateThreadInfos(global, chatId, repliesThreadInfos); let listedIds = selectListedIds(global, chatId, threadId); const outlyingIds = selectOutlyingIds(global, chatId, threadId); diff --git a/src/global/actions/api/sync.ts b/src/global/actions/api/sync.ts index ce6c17812..7afef9c40 100644 --- a/src/global/actions/api/sync.ts +++ b/src/global/actions/api/sync.ts @@ -139,7 +139,7 @@ async function loadAndReplaceMessages() { global = safeReplaceViewportIds(global, activeCurrentChatId, activeThreadId, listedIds); global = updateChats(global, buildCollectionByKey(result.chats, 'id')); global = updateUsers(global, buildCollectionByKey(result.users, 'id')); - global = updateThreadInfos(global, activeCurrentChatId, result.threadInfos); + global = updateThreadInfos(global, activeCurrentChatId, result.repliesThreadInfos); areMessagesLoaded = true; } diff --git a/src/global/actions/apiUpdaters/messages.ts b/src/global/actions/apiUpdaters/messages.ts index 27d3d5ba8..c1fd4e958 100644 --- a/src/global/actions/apiUpdaters/messages.ts +++ b/src/global/actions/apiUpdaters/messages.ts @@ -67,12 +67,12 @@ addActionHandler('apiUpdate', (global, actions, update) => { global = updateWithLocalMedia(global, chatId, id, message); global = updateListedAndViewportIds(global, actions, message as ApiMessage); - if (message.threadInfo) { + if (message.repliesThreadInfo) { global = updateThreadInfo( global, - message.threadInfo.chatId, - message.threadInfo.threadId, - message.threadInfo, + message.repliesThreadInfo.chatId, + message.repliesThreadInfo.threadId, + message.repliesThreadInfo, ); } @@ -185,12 +185,12 @@ addActionHandler('apiUpdate', (global, actions, update) => { global = updateWithLocalMedia(global, chatId, id, message); const newMessage = selectChatMessage(global, chatId, id)!; - if (message.threadInfo) { + if (message.repliesThreadInfo) { global = updateThreadInfo( global, - message.threadInfo.chatId, - message.threadInfo.threadId, - message.threadInfo, + message.repliesThreadInfo.chatId, + message.repliesThreadInfo.threadId, + message.repliesThreadInfo, ); } @@ -213,7 +213,7 @@ addActionHandler('apiUpdate', (global, actions, update) => { && chat.lastMessage?.id === message.id && selectIsChatWithBot(global, chat) && selectIsMessageInCurrentMessageList(global, chatId, message as ApiMessage) - && selectIsViewportNewest(global, chatId, message.threadInfo?.threadId || MAIN_THREAD_ID) + && selectIsViewportNewest(global, chatId, message.repliesThreadInfo?.threadId || MAIN_THREAD_ID) ) { actions.focusLastMessage(); } diff --git a/src/global/reducers/messages.ts b/src/global/reducers/messages.ts index ea3455d97..3b8e2a2da 100644 --- a/src/global/reducers/messages.ts +++ b/src/global/reducers/messages.ts @@ -271,7 +271,7 @@ export function deleteChatMessages( global = updateCurrentMessageList(global, chatId); } if (originalPost) { - global = updateChatMessage(global, fromChatId!, fromMessageId!, { threadInfo: undefined }); + global = updateChatMessage(global, fromChatId!, fromMessageId!, { repliesThreadInfo: undefined }); } }); }