Passcode: Fix migrating locked cache

This commit is contained in:
Alexander Zinchuk 2022-08-09 13:21:33 +02:00
parent c9c744822f
commit 61c6f5a145
2 changed files with 6 additions and 2 deletions

View File

@ -3,8 +3,10 @@ import { addActionHandler, setGlobal, getGlobal } from '../../index';
import { clearPasscodeSettings, updatePasscodeSettings } from '../../reducers'; import { clearPasscodeSettings, updatePasscodeSettings } from '../../reducers';
import { clearStoredSession, loadStoredSession, storeSession } from '../../../util/sessions'; import { clearStoredSession, loadStoredSession, storeSession } from '../../../util/sessions';
import { clearEncryptedSession, encryptSession, setupPasscode } from '../../../util/passcode'; import { clearEncryptedSession, encryptSession, setupPasscode } from '../../../util/passcode';
import { forceUpdateCache, serializeGlobal } from '../../cache'; import { forceUpdateCache, migrateCache, serializeGlobal } from '../../cache';
import { onBeforeUnload } from '../../../util/schedulers'; import { onBeforeUnload } from '../../../util/schedulers';
import { cloneDeep } from '../../../util/iteratees';
import { INITIAL_STATE } from '../../initialState';
let noLockOnUnload = false; let noLockOnUnload = false;
onBeforeUnload(() => { onBeforeUnload(() => {
@ -48,6 +50,8 @@ addActionHandler('unlockScreen', (global, actions, { sessionJson, globalJson })
storeSession(session, session.userId); storeSession(session, session.userId);
global = JSON.parse(globalJson); global = JSON.parse(globalJson);
migrateCache(global, cloneDeep(INITIAL_STATE));
setGlobal(updatePasscodeSettings( setGlobal(updatePasscodeSettings(
global, global,
{ {

View File

@ -137,7 +137,7 @@ function readCache(initialState: GlobalState): GlobalState {
}; };
} }
function migrateCache(cached: GlobalState, initialState: GlobalState) { export function migrateCache(cached: GlobalState, initialState: GlobalState) {
// Migrate from legacy setting names // Migrate from legacy setting names
if ('shouldAutoDownloadMediaFromContacts' in cached.settings.byKey) { if ('shouldAutoDownloadMediaFromContacts' in cached.settings.byKey) {
const { const {