diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index 1c3735afa..e9d0bae00 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -116,7 +116,7 @@ addActionHandler('preloadTopChatMessages', async (global, actions): Promise { const { - id, threadId = MAIN_THREAD_ID, + id, threadId = MAIN_THREAD_ID, noRequestThreadInfoUpdate, } = payload; if (!id) { return; @@ -142,7 +142,7 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => { actions.requestChatUpdate({ chatId: id }); } - if (threadId !== MAIN_THREAD_ID) { + if (threadId !== MAIN_THREAD_ID && !noRequestThreadInfoUpdate) { actions.requestThreadInfoUpdate({ chatId: id, threadId }); } }); @@ -160,7 +160,9 @@ addActionHandler('openComments', async (global, actions, payload): Promise return; } - actions.openChat({ id, threadId, tabId }); + actions.openChat({ + id, threadId, tabId, noRequestThreadInfoUpdate: true, + }); const result = await callApi('requestThreadInfoUpdate', { chat, threadId, originChannelId }); if (!result) { @@ -176,9 +178,15 @@ addActionHandler('openComments', async (global, actions, payload): Promise threadId: result.topMessageId, tabId, shouldReplaceLast: true, + noRequestThreadInfoUpdate: true, }); } else { - actions.openChat({ id, threadId: topMessageId, tabId }); + actions.openChat({ + id, + threadId: topMessageId, + tabId, + noRequestThreadInfoUpdate: true, + }); } } }); diff --git a/src/global/actions/api/messages.ts b/src/global/actions/api/messages.ts index ab67adac0..9994c8faf 100644 --- a/src/global/actions/api/messages.ts +++ b/src/global/actions/api/messages.ts @@ -80,7 +80,7 @@ import { selectSendAs, selectSponsoredMessage, selectTabState, - selectThreadIdFromMessage, + selectThreadIdFromMessage, selectThreadOriginChat, selectThreadTopMessageId, selectUser, selectViewportIds, @@ -870,7 +870,9 @@ addActionHandler('requestThreadInfoUpdate', async (global, actions, payload): Pr return; } - const result = await callApi('requestThreadInfoUpdate', { chat, threadId }); + const originChannelId = selectThreadOriginChat(global, chatId, threadId)?.id; + + const result = await callApi('requestThreadInfoUpdate', { chat, threadId, originChannelId }); if (!result) return; global = getGlobal(); global = addUsers(global, buildCollectionByKey(result.users, 'id')); diff --git a/src/global/types.ts b/src/global/types.ts index 9bc4ebf5b..f80df0d99 100644 --- a/src/global/types.ts +++ b/src/global/types.ts @@ -1606,6 +1606,7 @@ export interface ActionPayloads { shouldReplaceHistory?: boolean; shouldReplaceLast?: boolean; noForumTopicPanel?: boolean; + noRequestThreadInfoUpdate?: boolean; } & WithTabId; openComments: { id: string;