Comments: Fix opening invalid posts (#2915)
This commit is contained in:
parent
e070ffe8a0
commit
743715cdb1
@ -116,7 +116,7 @@ addActionHandler('preloadTopChatMessages', async (global, actions): Promise<void
|
||||
|
||||
addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
||||
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<void>
|
||||
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<void>
|
||||
threadId: result.topMessageId,
|
||||
tabId,
|
||||
shouldReplaceLast: true,
|
||||
noRequestThreadInfoUpdate: true,
|
||||
});
|
||||
} else {
|
||||
actions.openChat({ id, threadId: topMessageId, tabId });
|
||||
actions.openChat({
|
||||
id,
|
||||
threadId: topMessageId,
|
||||
tabId,
|
||||
noRequestThreadInfoUpdate: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -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'));
|
||||
|
||||
@ -1606,6 +1606,7 @@ export interface ActionPayloads {
|
||||
shouldReplaceHistory?: boolean;
|
||||
shouldReplaceLast?: boolean;
|
||||
noForumTopicPanel?: boolean;
|
||||
noRequestThreadInfoUpdate?: boolean;
|
||||
} & WithTabId;
|
||||
openComments: {
|
||||
id: string;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user