mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
[PM-5433] Migrate Showcards and Showidentities on current tab to state provider (#8252)
* added showCards and Identities to vault settings and then added migration file * added migration file and removed fields from domain * fixed merge conflicts
This commit is contained in:
@@ -8,10 +8,29 @@ export abstract class VaultSettingsService {
|
||||
* The observable updates when the setting changes.
|
||||
*/
|
||||
enablePasskeys$: Observable<boolean>;
|
||||
/**
|
||||
* An observable monitoring the state of the show cards on the current tab.
|
||||
*/
|
||||
showCardsCurrentTab$: Observable<boolean>;
|
||||
/**
|
||||
* An observable monitoring the state of the show identities on the current tab.
|
||||
*/
|
||||
showIdentitiesCurrentTab$: Observable<boolean>;
|
||||
/**
|
||||
|
||||
/**
|
||||
* Saves the enable passkeys setting to disk.
|
||||
* @param value The new value for the passkeys setting.
|
||||
*/
|
||||
setEnablePasskeys: (value: boolean) => Promise<void>;
|
||||
/**
|
||||
* Saves the show cards on tab page setting to disk.
|
||||
* @param value The new value for the show cards on tab page setting.
|
||||
*/
|
||||
setShowCardsCurrentTab: (value: boolean) => Promise<void>;
|
||||
/**
|
||||
* Saves the show identities on tab page setting to disk.
|
||||
* @param value The new value for the show identities on tab page setting.
|
||||
*/
|
||||
setShowIdentitiesCurrentTab: (value: boolean) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { VAULT_SETTINGS_DISK, KeyDefinition } from "../../../platform/state";
|
||||
|
||||
export const USER_ENABLE_PASSKEYS = new KeyDefinition<boolean>(
|
||||
VAULT_SETTINGS_DISK,
|
||||
"enablePasskeys",
|
||||
{
|
||||
deserializer: (obj) => obj,
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
import { VAULT_SETTINGS_DISK, KeyDefinition } from "../../../platform/state";
|
||||
|
||||
export const USER_ENABLE_PASSKEYS = new KeyDefinition<boolean>(
|
||||
VAULT_SETTINGS_DISK,
|
||||
"enablePasskeys",
|
||||
{
|
||||
deserializer: (obj) => obj,
|
||||
},
|
||||
);
|
||||
|
||||
export const SHOW_CARDS_CURRENT_TAB = new KeyDefinition<boolean>(
|
||||
VAULT_SETTINGS_DISK,
|
||||
"showCardsCurrentTab",
|
||||
{
|
||||
deserializer: (obj) => obj,
|
||||
},
|
||||
);
|
||||
|
||||
export const SHOW_IDENTITIES_CURRENT_TAB = new KeyDefinition<boolean>(
|
||||
VAULT_SETTINGS_DISK,
|
||||
"showIdentitiesCurrentTab",
|
||||
{ deserializer: (obj) => obj },
|
||||
);
|
||||
@@ -1,8 +1,12 @@
|
||||
import { Observable, map } from "rxjs";
|
||||
|
||||
import { GlobalState, StateProvider } from "../../../platform/state";
|
||||
import { ActiveUserState, GlobalState, StateProvider } from "../../../platform/state";
|
||||
import { VaultSettingsService as VaultSettingsServiceAbstraction } from "../../abstractions/vault-settings/vault-settings.service";
|
||||
import { USER_ENABLE_PASSKEYS } from "../key-state/enable-passkey.state";
|
||||
import {
|
||||
SHOW_CARDS_CURRENT_TAB,
|
||||
SHOW_IDENTITIES_CURRENT_TAB,
|
||||
USER_ENABLE_PASSKEYS,
|
||||
} from "../key-state/vault-settings.state";
|
||||
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction}
|
||||
@@ -10,7 +14,6 @@ import { USER_ENABLE_PASSKEYS } from "../key-state/enable-passkey.state";
|
||||
export class VaultSettingsService implements VaultSettingsServiceAbstraction {
|
||||
private enablePasskeysState: GlobalState<boolean> =
|
||||
this.stateProvider.getGlobal(USER_ENABLE_PASSKEYS);
|
||||
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.enablePasskeys$}
|
||||
*/
|
||||
@@ -18,8 +21,40 @@ export class VaultSettingsService implements VaultSettingsServiceAbstraction {
|
||||
map((x) => x ?? true),
|
||||
);
|
||||
|
||||
private showCardsCurrentTabState: ActiveUserState<boolean> =
|
||||
this.stateProvider.getActive(SHOW_CARDS_CURRENT_TAB);
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.showCardsCurrentTab$}
|
||||
*/
|
||||
readonly showCardsCurrentTab$: Observable<boolean> = this.showCardsCurrentTabState.state$.pipe(
|
||||
map((x) => x ?? true),
|
||||
);
|
||||
|
||||
private showIdentitiesCurrentTabState: ActiveUserState<boolean> = this.stateProvider.getActive(
|
||||
SHOW_IDENTITIES_CURRENT_TAB,
|
||||
);
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.showIdentitiesCurrentTab$}
|
||||
*/
|
||||
readonly showIdentitiesCurrentTab$: Observable<boolean> =
|
||||
this.showIdentitiesCurrentTabState.state$.pipe(map((x) => x ?? true));
|
||||
|
||||
constructor(private stateProvider: StateProvider) {}
|
||||
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.setShowCardsCurrentTab}
|
||||
*/
|
||||
async setShowCardsCurrentTab(value: boolean): Promise<void> {
|
||||
await this.showCardsCurrentTabState.update(() => value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.setDontShowIdentitiesCurrentTab}
|
||||
*/
|
||||
async setShowIdentitiesCurrentTab(value: boolean): Promise<void> {
|
||||
await this.showIdentitiesCurrentTabState.update(() => value);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link VaultSettingsServiceAbstraction.setEnablePasskeys}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user