From af7da0e94275f0f2899c3889fdd7aa4533bffe11 Mon Sep 17 00:00:00 2001 From: Daniel James Smith Date: Mon, 24 Jan 2022 20:37:52 +0100 Subject: [PATCH] Ensure that initialization and migration only run once (#631) --- common/src/services/state.service.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/src/services/state.service.ts b/common/src/services/state.service.ts index f97c36f1403..a0178fd3b53 100644 --- a/common/src/services/state.service.ts +++ b/common/src/services/state.service.ts @@ -58,6 +58,8 @@ export class StateService protected state: State = new State(); + private hasBeenInited: boolean = false; + constructor( protected storageService: StorageService, protected secureStorageService: StorageService, @@ -67,11 +69,16 @@ export class StateService ) {} async init(): Promise { + if (this.hasBeenInited) { + return; + } + if (await this.stateMigrationService.needsMigration()) { await this.stateMigrationService.migrate(); } await this.initAccountState(); + this.hasBeenInited = true; } async initAccountState() {