Profile Info: Save state for multi-tabs (#2434)

This commit is contained in:
Alexander Zinchuk 2023-01-30 19:13:15 +01:00
parent fa7971a6a0
commit 6c4acf8935
5 changed files with 10 additions and 3 deletions

View File

@ -87,6 +87,7 @@ addActionHandler('openChatWithInfo', (global, actions, payload): ActionReturnTyp
...selectTabState(global, tabId),
isChatInfoShown: true,
}, tabId);
global = { ...global, lastIsChatInfoShown: true };
setGlobal(global);
actions.openChat({ ...payload, tabId });

View File

@ -26,9 +26,12 @@ const MAX_STORED_EMOJIS = 8 * 4; // Represents four rows of recent emojis
addActionHandler('toggleChatInfo', (global, actions, payload): ActionReturnType => {
const { force, tabId = getCurrentTabId() } = payload || {};
return updateTabState(global, {
isChatInfoShown: force !== undefined ? force : !selectTabState(global, tabId).isChatInfoShown,
}, tabId);
const isChatInfoShown = force !== undefined ? force : !selectTabState(global, tabId).isChatInfoShown;
global = updateTabState(global, { isChatInfoShown }, tabId);
global = { ...global, lastIsChatInfoShown: isChatInfoShown };
return global;
});
addActionHandler('setLeftColumnWidth', (global, actions, payload): ActionReturnType => {

View File

@ -384,6 +384,7 @@ export function serializeGlobal<T extends GlobalState>(global: T) {
'serviceNotifications',
'attachmentSettings',
'leftColumnWidth',
'lastIsChatInfoShown',
]),
customEmojis: reduceCustomEmojis(global),
users: reduceUsers(global),

View File

@ -48,6 +48,7 @@ addActionHandler('init', (global, actions, payload): ActionReturnType => {
const initialTabState = cloneDeep(INITIAL_TAB_STATE);
initialTabState.id = tabId;
initialTabState.isChatInfoShown = Boolean(global.lastIsChatInfoShown);
global = {
...global,
byTabId: {

View File

@ -534,6 +534,7 @@ export type GlobalState = {
serverTimeOffset: number;
blurredTabTokens: number[];
leftColumnWidth?: number;
lastIsChatInfoShown?: boolean;
initialUnreadNotifications?: number;
notificationIndex?: number;
allNotificationsCount?: number;