Logout: Fix last chat opening after logging out (#2827)
This commit is contained in:
parent
5d1c4a8c87
commit
f7ff7bf598
@ -30,7 +30,7 @@ import { forceWebsync } from '../../../util/websync';
|
||||
import { addUsers, clearGlobalForLockScreen, updatePasscodeSettings } from '../../reducers';
|
||||
import { clearEncryptedSession, encryptSession, forgetPasscode } from '../../../util/passcode';
|
||||
import { serializeGlobal } from '../../cache';
|
||||
import { parseInitialLocationHash } from '../../../util/routing';
|
||||
import { parseInitialLocationHash, resetInitialLocationHash } from '../../../util/routing';
|
||||
import type { ActionReturnType } from '../../types';
|
||||
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
||||
import { buildCollectionByKey } from '../../../util/iteratees';
|
||||
@ -157,6 +157,7 @@ addActionHandler('signOut', async (global, actions, payload): Promise<void> => {
|
||||
if ('leaveGroupCall' in actions) actions.leaveGroupCall({ tabId: getCurrentTabId() });
|
||||
|
||||
try {
|
||||
resetInitialLocationHash();
|
||||
await unsubscribe();
|
||||
await callApi('destroy');
|
||||
await forceWebsync(false);
|
||||
|
||||
@ -8,7 +8,6 @@ import { IS_IOS } from '../util/windowEnvironment';
|
||||
import useSyncEffect from './useSyncEffect';
|
||||
import useEffectOnce from './useEffectOnce';
|
||||
|
||||
export const LOCATION_HASH = window.location.hash;
|
||||
const PATH_BASE = `${window.location.pathname}${window.location.search}`;
|
||||
// Carefully selected by swiping and observing visual changes
|
||||
// TODO: may be different on other devices such as iPad, maybe take dpi into account?
|
||||
|
||||
@ -1,12 +1,24 @@
|
||||
import type { MessageListType } from '../global/types';
|
||||
import { MAIN_THREAD_ID } from '../api/types';
|
||||
import { LOCATION_HASH } from '../hooks/useHistoryBack';
|
||||
import { IS_MOCKED_CLIENT } from '../config';
|
||||
|
||||
let parsedInitialLocationHash: Record<string, string> | undefined;
|
||||
let messageHash: string | undefined;
|
||||
let isAlreadyParsed = false;
|
||||
|
||||
let LOCATION_HASH: string | undefined = window.location.hash;
|
||||
|
||||
export function getInitialLocationHash() {
|
||||
return LOCATION_HASH;
|
||||
}
|
||||
|
||||
export function resetInitialLocationHash() {
|
||||
LOCATION_HASH = undefined;
|
||||
isAlreadyParsed = false;
|
||||
messageHash = undefined;
|
||||
parsedInitialLocationHash = undefined;
|
||||
}
|
||||
|
||||
export const createLocationHash = (chatId: string, type: MessageListType, threadId: number): string => {
|
||||
const displayType = type === 'thread' ? undefined : type;
|
||||
const parts = threadId === MAIN_THREAD_ID ? [chatId, displayType] : [chatId, threadId, displayType];
|
||||
@ -55,21 +67,22 @@ export function parseInitialLocationHash() {
|
||||
|
||||
if (isAlreadyParsed) return undefined;
|
||||
|
||||
if (!LOCATION_HASH) return undefined;
|
||||
const locationHash = getInitialLocationHash();
|
||||
if (!locationHash) return undefined;
|
||||
|
||||
let parsedHash = LOCATION_HASH ? LOCATION_HASH.replace(/^#/, '') : undefined;
|
||||
if (parsedHash?.includes('?')) {
|
||||
let parsedHash = locationHash.replace(/^#/, '');
|
||||
if (parsedHash.includes('?')) {
|
||||
[messageHash, parsedHash] = parsedHash.split('?');
|
||||
if (!IS_MOCKED_CLIENT) {
|
||||
window.location.hash = messageHash;
|
||||
}
|
||||
} else if (parsedHash?.includes('=')) {
|
||||
} else if (parsedHash.includes('=')) {
|
||||
if (!IS_MOCKED_CLIENT) {
|
||||
window.location.hash = '';
|
||||
}
|
||||
}
|
||||
|
||||
parsedInitialLocationHash = parsedHash?.includes('=') ? parsedHash?.split('&').reduce((acc, cur) => {
|
||||
parsedInitialLocationHash = parsedHash.includes('=') ? parsedHash.split('&').reduce((acc, cur) => {
|
||||
const [key, value] = cur.split('=');
|
||||
acc[key] = value;
|
||||
return acc;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user