2022-01-04 17:15:58 +01:00
|
|
|
import { StateService as BaseStateService } from "jslib-common/services/state.service";
|
|
|
|
|
|
|
|
import { Account } from "../models/account";
|
2022-02-02 17:20:15 +01:00
|
|
|
import { GlobalState } from "../models/globalState";
|
2022-01-04 17:15:58 +01:00
|
|
|
|
2022-02-02 17:20:15 +01:00
|
|
|
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
|
2022-01-04 17:15:58 +01:00
|
|
|
|
2022-02-02 17:20:15 +01:00
|
|
|
import { StorageOptions } from "jslib-common/models/domain/storageOptions";
|
|
|
|
|
|
|
|
export class StateService
|
|
|
|
extends BaseStateService<Account, GlobalState>
|
|
|
|
implements StateServiceAbstraction
|
|
|
|
{
|
2022-01-04 17:15:58 +01:00
|
|
|
async addAccount(account: Account) {
|
|
|
|
// Apply web overides to default account values
|
|
|
|
account = new Account(account);
|
|
|
|
await super.addAccount(account);
|
|
|
|
}
|
2022-02-02 17:20:15 +01:00
|
|
|
|
|
|
|
async getRememberEmail(options?: StorageOptions) {
|
|
|
|
return (
|
|
|
|
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
|
|
|
)?.rememberEmail;
|
|
|
|
}
|
|
|
|
|
|
|
|
async setRememberEmail(value: boolean, options?: StorageOptions): Promise<void> {
|
|
|
|
const globals = await this.getGlobals(
|
|
|
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
|
|
|
);
|
|
|
|
globals.rememberEmail = value;
|
|
|
|
await this.saveGlobals(
|
|
|
|
globals,
|
|
|
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
|
|
|
);
|
|
|
|
}
|
2022-01-04 17:15:58 +01:00
|
|
|
}
|