From 2c9ccefa12caad56ed57e19ef83cd97ac95691e6 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Thu, 28 Jul 2022 10:14:28 +1000 Subject: [PATCH] Do not set state to null and throw if this occurs (#3191) --- libs/common/src/services/state.service.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/common/src/services/state.service.ts b/libs/common/src/services/state.service.ts index 8fe91210f6..22836e0de7 100644 --- a/libs/common/src/services/state.service.ts +++ b/libs/common/src/services/state.service.ts @@ -2674,10 +2674,9 @@ export class StateService< protected async clearDecryptedDataForActiveUser(): Promise { await this.updateState(async (state) => { const userId = state?.activeUserId; - if (userId == null || state?.accounts[userId]?.data == null) { - return; + if (userId != null && state?.accounts[userId]?.data != null) { + state.accounts[userId].data = new AccountData(); } - state.accounts[userId].data = new AccountData(); return state; }); @@ -2756,6 +2755,9 @@ export class StateService< ) { await this.state().then(async (state) => { const updatedState = await stateUpdater(state); + if (updatedState == null) { + throw new Error("Attempted to update state to null value"); + } await this.setState(updatedState); });