Comments: Fix header blink when opening (#2831)
This commit is contained in:
parent
55d711e683
commit
a7fb1958a1
@ -160,7 +160,7 @@ addActionHandler('openComments', async (global, actions, payload): Promise<void>
|
||||
return;
|
||||
}
|
||||
|
||||
actions.openChat({ id: TMP_CHAT_ID, tabId });
|
||||
actions.openChat({ id, threadId, tabId });
|
||||
|
||||
const result = await callApi('requestThreadInfoUpdate', { chat, threadId, originChannelId });
|
||||
if (!result) {
|
||||
@ -171,7 +171,12 @@ addActionHandler('openComments', async (global, actions, payload): Promise<void>
|
||||
global = addUsers(global, buildCollectionByKey(result.users, 'id'));
|
||||
setGlobal(global);
|
||||
|
||||
actions.openChat({ id, threadId: result.topMessageId, tabId });
|
||||
actions.openChat({
|
||||
id,
|
||||
threadId: result.topMessageId,
|
||||
tabId,
|
||||
shouldReplaceLast: true,
|
||||
});
|
||||
} else {
|
||||
actions.openChat({ id, threadId: topMessageId, tabId });
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
||||
threadId = MAIN_THREAD_ID,
|
||||
type = 'thread',
|
||||
shouldReplaceHistory = false,
|
||||
shouldReplaceLast = false,
|
||||
noForumTopicPanel,
|
||||
tabId = getCurrentTabId(),
|
||||
} = payload;
|
||||
@ -71,7 +72,7 @@ addActionHandler('openChat', (global, actions, payload): ActionReturnType => {
|
||||
|
||||
actions.updatePageTitle({ tabId });
|
||||
|
||||
return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory, tabId);
|
||||
return updateCurrentMessageList(global, id, threadId, type, shouldReplaceHistory, shouldReplaceLast, tabId);
|
||||
});
|
||||
|
||||
addActionHandler('openChatInNewTab', (global, actions, payload): ActionReturnType => {
|
||||
@ -82,7 +83,7 @@ addActionHandler('openChatInNewTab', (global, actions, payload): ActionReturnTyp
|
||||
|
||||
addActionHandler('openPreviousChat', (global, actions, payload): ActionReturnType => {
|
||||
const { tabId = getCurrentTabId() } = payload || {};
|
||||
return updateCurrentMessageList(global, undefined, undefined, undefined, undefined, tabId);
|
||||
return updateCurrentMessageList(global, undefined, undefined, undefined, undefined, undefined, tabId);
|
||||
});
|
||||
|
||||
addActionHandler('openChatWithInfo', (global, actions, payload): ActionReturnType => {
|
||||
|
||||
@ -45,6 +45,7 @@ export function updateCurrentMessageList<T extends GlobalState>(
|
||||
threadId: number = MAIN_THREAD_ID,
|
||||
type: MessageListType = 'thread',
|
||||
shouldReplaceHistory?: boolean,
|
||||
shouldReplaceLast?: boolean,
|
||||
...[tabId = getCurrentTabId()]: TabArgs<T>
|
||||
): T {
|
||||
const { messageLists } = selectTabState(global, tabId);
|
||||
@ -54,7 +55,7 @@ export function updateCurrentMessageList<T extends GlobalState>(
|
||||
} else if (chatId) {
|
||||
const last = messageLists[messageLists.length - 1];
|
||||
if (!last || last.chatId !== chatId || last.threadId !== threadId || last.type !== type) {
|
||||
if (last && last.chatId === TMP_CHAT_ID) {
|
||||
if (last && (last.chatId === TMP_CHAT_ID || shouldReplaceLast)) {
|
||||
newMessageLists = [...messageLists.slice(0, -1), { chatId, threadId, type }];
|
||||
} else {
|
||||
newMessageLists = [...messageLists, { chatId, threadId, type }];
|
||||
@ -310,7 +311,7 @@ export function deleteChatMessages<T extends GlobalState>(
|
||||
const originalPost = selectChatMessage(global, fromChatId!, fromMessageId!);
|
||||
|
||||
if (canDeleteCurrentThread && currentThreadId === fromMessageId) {
|
||||
global = updateCurrentMessageList(global, chatId, undefined, undefined, undefined, tabId);
|
||||
global = updateCurrentMessageList(global, chatId, undefined, undefined, undefined, undefined, tabId);
|
||||
}
|
||||
if (originalPost) {
|
||||
global = updateChatMessage(global, fromChatId!, fromMessageId!, { repliesThreadInfo: undefined });
|
||||
|
||||
@ -1606,6 +1606,7 @@ export interface ActionPayloads {
|
||||
threadId?: number;
|
||||
type?: MessageListType;
|
||||
shouldReplaceHistory?: boolean;
|
||||
shouldReplaceLast?: boolean;
|
||||
noForumTopicPanel?: boolean;
|
||||
} & WithTabId;
|
||||
openComments: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user