mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[SM-537] add local storage persistence for onboarding tasks (#4880)
* add local storage check for tasks * associate saved tasks with organization ID * remove redundant parenthesis * revert last commit * add falsy check * use distinctUntilChanged * remove extra observable * apply code review
This commit is contained in:
@@ -357,4 +357,12 @@ export abstract class StateService<T extends Account = Account> {
|
||||
|
||||
getAvatarColor: (options?: StorageOptions) => Promise<string | null | undefined>;
|
||||
setAvatarColor: (value: string, options?: StorageOptions) => Promise<void>;
|
||||
|
||||
getSMOnboardingTasks: (
|
||||
options?: StorageOptions
|
||||
) => Promise<Record<string, Record<string, boolean>>>;
|
||||
setSMOnboardingTasks: (
|
||||
value: Record<string, Record<string, boolean>>,
|
||||
options?: StorageOptions
|
||||
) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ export class AccountSettings {
|
||||
serverConfig?: ServerConfigData;
|
||||
approveLoginRequests?: boolean;
|
||||
avatarColor?: string;
|
||||
smOnboardingTasks?: Record<string, Record<string, boolean>>;
|
||||
|
||||
static fromJSON(obj: Jsonify<AccountSettings>): AccountSettings {
|
||||
if (obj == null) {
|
||||
|
||||
@@ -2364,6 +2364,28 @@ export class StateService<
|
||||
);
|
||||
}
|
||||
|
||||
async getSMOnboardingTasks(
|
||||
options?: StorageOptions
|
||||
): Promise<Record<string, Record<string, boolean>>> {
|
||||
return (
|
||||
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||
)?.settings?.smOnboardingTasks;
|
||||
}
|
||||
|
||||
async setSMOnboardingTasks(
|
||||
value: Record<string, Record<string, boolean>>,
|
||||
options?: StorageOptions
|
||||
): Promise<void> {
|
||||
const account = await this.getAccount(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
account.settings.smOnboardingTasks = value;
|
||||
return await this.saveAccount(
|
||||
account,
|
||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||
);
|
||||
}
|
||||
|
||||
protected async getGlobals(options: StorageOptions): Promise<TGlobalState> {
|
||||
let globals: TGlobalState;
|
||||
if (this.useMemory(options.storageLocation)) {
|
||||
|
||||
Reference in New Issue
Block a user