Do not set state to null and throw if this occurs (#3191)

This commit is contained in:
Thomas Rittson 2022-07-28 10:14:28 +10:00 committed by GitHub
parent 76b1798e23
commit 2c9ccefa12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -2674,10 +2674,9 @@ export class StateService<
protected async clearDecryptedDataForActiveUser(): Promise<void> {
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);
});