Save localData to local storage instead of in memory (#683)

This commit is contained in:
Robyn MacCallum 2022-02-14 16:32:55 -05:00 committed by GitHub
parent 240fc154ab
commit 5de59c32ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -1613,16 +1613,19 @@ export class StateService<
}
async getLocalData(options?: StorageOptions): Promise<any> {
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
?.data?.localData;
return (
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
)?.data?.localData;
}
async setLocalData(value: string, options?: StorageOptions): Promise<void> {
const account = await this.getAccount(
this.reconcileOptions(options, this.defaultInMemoryOptions)
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
account.data.localData = value;
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
await this.saveAccount(
account,
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
);
}
async getLocale(options?: StorageOptions): Promise<string> {