1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 15:23:33 +00:00
Files
browser/src/services/state.service.ts
2022-02-03 13:54:15 -05:00

37 lines
1.2 KiB
TypeScript

import { StateService as BaseStateService } from "jslib-common/services/state.service";
import { Account } from "../models/account";
import { GlobalState } from "../models/globalState";
import { StateService as StateServiceAbstraction } from "../abstractions/state.service";
import { StorageOptions } from "jslib-common/models/domain/storageOptions";
export class StateService
extends BaseStateService<GlobalState, Account>
implements StateServiceAbstraction
{
async addAccount(account: Account) {
// Apply web overides to default account values
account = new Account(account);
await super.addAccount(account);
}
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())
);
}
}