Message List: Navigate back when opening chat that is previous in the stack
This commit is contained in:
parent
bceec156b5
commit
e731712b74
@ -17,8 +17,7 @@ import {
|
|||||||
} from '../../util/iteratees';
|
} from '../../util/iteratees';
|
||||||
import { isLocalMessageId, type MessageKey } from '../../util/keys/messageKey';
|
import { isLocalMessageId, type MessageKey } from '../../util/keys/messageKey';
|
||||||
import {
|
import {
|
||||||
hasMessageTtl, isMediaLoadableInViewer,
|
hasMessageTtl, isMediaLoadableInViewer, mergeIdRanges, orderHistoryIds, orderPinnedIds,
|
||||||
mergeIdRanges, orderHistoryIds, orderPinnedIds,
|
|
||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import {
|
import {
|
||||||
selectChatMessage,
|
selectChatMessage,
|
||||||
@ -58,10 +57,18 @@ export function updateCurrentMessageList<T extends GlobalState>(
|
|||||||
if (shouldReplaceHistory || (IS_TEST && !IS_MOCKED_CLIENT)) {
|
if (shouldReplaceHistory || (IS_TEST && !IS_MOCKED_CLIENT)) {
|
||||||
newMessageLists = chatId ? [{ chatId, threadId, type }] : [];
|
newMessageLists = chatId ? [{ chatId, threadId, type }] : [];
|
||||||
} else if (chatId) {
|
} else if (chatId) {
|
||||||
const last = messageLists[messageLists.length - 1];
|
const current = messageLists[messageLists.length - 1];
|
||||||
if (!last || last.chatId !== chatId || last.threadId !== threadId || last.type !== type) {
|
if (current?.chatId === chatId && current.threadId === threadId && current.type === type) {
|
||||||
if (last && (last.chatId === TMP_CHAT_ID || shouldReplaceLast)) {
|
return global;
|
||||||
newMessageLists = [...messageLists.slice(0, -1), { chatId, threadId, type }];
|
}
|
||||||
|
|
||||||
|
if (current && (current.chatId === TMP_CHAT_ID || shouldReplaceLast)) {
|
||||||
|
newMessageLists = [...messageLists.slice(0, -1), { chatId, threadId, type }];
|
||||||
|
} else {
|
||||||
|
const previous = messageLists[messageLists.length - 2];
|
||||||
|
|
||||||
|
if (previous?.chatId === chatId && previous.threadId === threadId && previous.type === type) {
|
||||||
|
newMessageLists = messageLists.slice(0, -1);
|
||||||
} else {
|
} else {
|
||||||
newMessageLists = [...messageLists, { chatId, threadId, type }];
|
newMessageLists = [...messageLists, { chatId, threadId, type }];
|
||||||
}
|
}
|
||||||
@ -599,10 +606,12 @@ export function updateThreadInfos<T extends GlobalState>(
|
|||||||
global: T, updates: Partial<ApiThreadInfo>[],
|
global: T, updates: Partial<ApiThreadInfo>[],
|
||||||
): T {
|
): T {
|
||||||
updates.forEach((update) => {
|
updates.forEach((update) => {
|
||||||
global = updateThreadInfo(global,
|
global = updateThreadInfo(
|
||||||
|
global,
|
||||||
update.isCommentsInfo ? update.originChannelId! : update.chatId!,
|
update.isCommentsInfo ? update.originChannelId! : update.chatId!,
|
||||||
update.isCommentsInfo ? update.originMessageId! : update.threadId!,
|
update.isCommentsInfo ? update.originMessageId! : update.threadId!,
|
||||||
update);
|
update,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return global;
|
return global;
|
||||||
@ -645,26 +654,28 @@ export function updateQuickReplyMessages<T extends GlobalState>(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateFocusedMessage<T extends GlobalState>({
|
export function updateFocusedMessage<T extends GlobalState>(
|
||||||
global,
|
{
|
||||||
chatId,
|
global,
|
||||||
messageId,
|
chatId,
|
||||||
threadId = MAIN_THREAD_ID,
|
messageId,
|
||||||
noHighlight = false,
|
threadId = MAIN_THREAD_ID,
|
||||||
isResizingContainer = false,
|
noHighlight = false,
|
||||||
quote,
|
isResizingContainer = false,
|
||||||
scrollTargetPosition,
|
quote,
|
||||||
}: {
|
scrollTargetPosition,
|
||||||
global: T;
|
}: {
|
||||||
chatId?: string;
|
global: T;
|
||||||
messageId?: number;
|
chatId?: string;
|
||||||
threadId?: ThreadId;
|
messageId?: number;
|
||||||
noHighlight?: boolean;
|
threadId?: ThreadId;
|
||||||
isResizingContainer?: boolean;
|
noHighlight?: boolean;
|
||||||
quote?: string;
|
isResizingContainer?: boolean;
|
||||||
scrollTargetPosition?: ScrollTargetPosition;
|
quote?: string;
|
||||||
},
|
scrollTargetPosition?: ScrollTargetPosition;
|
||||||
...[tabId = getCurrentTabId()]: TabArgs<T>): T {
|
},
|
||||||
|
...[tabId = getCurrentTabId()]: TabArgs<T>
|
||||||
|
): T {
|
||||||
return updateTabState(global, {
|
return updateTabState(global, {
|
||||||
focusedMessage: {
|
focusedMessage: {
|
||||||
...selectTabState(global, tabId).focusedMessage,
|
...selectTabState(global, tabId).focusedMessage,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user