mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-09 09:51:02 +01:00
[bug] Persistantly store collapsedGroupings (#686)
Collapsed groupings have regressed to not maintaining their state through restarting clients. The state mangement refactor erroniously began saving this field to memory instead of disk, but there were some other issues that changing this brought on that are also fixed in this commit. Changes: 1. Save collapsedGroupings persistantly in StateService 2. Adjust the type of collapsedGroupings on the Account model from a Set<string> to a string[] * This is the way we were storing this value in previous releases, and saving the entire set object breaks. 3. Adjust the StateService getter/setter for collapsedGroupings to expect a string[] 4. Extract a string[] from the GroupingsComponent groupings that is a Set<string> before saving
This commit is contained in:
parent
b65a2da18a
commit
a6092916d8
@ -151,7 +151,7 @@ export class GroupingsComponent {
|
|||||||
} else {
|
} else {
|
||||||
this.collapsedGroupings.add(id);
|
this.collapsedGroupings.add(id);
|
||||||
}
|
}
|
||||||
await this.stateService.setCollapsedGroupings(this.collapsedGroupings);
|
await this.stateService.setCollapsedGroupings(Array.from(this.collapsedGroupings));
|
||||||
}
|
}
|
||||||
|
|
||||||
isCollapsed(grouping: FolderView | CollectionView, idPrefix = "") {
|
isCollapsed(grouping: FolderView | CollectionView, idPrefix = "") {
|
||||||
|
@ -63,8 +63,8 @@ export abstract class StateService<T extends Account = Account> {
|
|||||||
getCanAccessPremium: (options?: StorageOptions) => Promise<boolean>;
|
getCanAccessPremium: (options?: StorageOptions) => Promise<boolean>;
|
||||||
getClearClipboard: (options?: StorageOptions) => Promise<number>;
|
getClearClipboard: (options?: StorageOptions) => Promise<number>;
|
||||||
setClearClipboard: (value: number, options?: StorageOptions) => Promise<void>;
|
setClearClipboard: (value: number, options?: StorageOptions) => Promise<void>;
|
||||||
getCollapsedGroupings: (options?: StorageOptions) => Promise<Set<string>>;
|
getCollapsedGroupings: (options?: StorageOptions) => Promise<string[]>;
|
||||||
setCollapsedGroupings: (value: Set<string>, options?: StorageOptions) => Promise<void>;
|
setCollapsedGroupings: (value: string[], options?: StorageOptions) => Promise<void>;
|
||||||
getConvertAccountToKeyConnector: (options?: StorageOptions) => Promise<boolean>;
|
getConvertAccountToKeyConnector: (options?: StorageOptions) => Promise<boolean>;
|
||||||
setConvertAccountToKeyConnector: (value: boolean, options?: StorageOptions) => Promise<void>;
|
setConvertAccountToKeyConnector: (value: boolean, options?: StorageOptions) => Promise<void>;
|
||||||
getCryptoMasterKey: (options?: StorageOptions) => Promise<SymmetricCryptoKey>;
|
getCryptoMasterKey: (options?: StorageOptions) => Promise<SymmetricCryptoKey>;
|
||||||
|
@ -54,7 +54,7 @@ export class AccountData {
|
|||||||
GeneratedPasswordHistory[]
|
GeneratedPasswordHistory[]
|
||||||
> = new EncryptionPair<GeneratedPasswordHistory[], GeneratedPasswordHistory[]>();
|
> = new EncryptionPair<GeneratedPasswordHistory[], GeneratedPasswordHistory[]>();
|
||||||
addEditCipherInfo?: any;
|
addEditCipherInfo?: any;
|
||||||
collapsedGroupings?: Set<string>;
|
collapsedGroupings?: string[];
|
||||||
eventCollection?: EventData[];
|
eventCollection?: EventData[];
|
||||||
organizations?: { [id: string]: OrganizationData };
|
organizations?: { [id: string]: OrganizationData };
|
||||||
providers?: { [id: string]: ProviderData };
|
providers?: { [id: string]: ProviderData };
|
||||||
|
@ -388,17 +388,21 @@ export class StateService<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCollapsedGroupings(options?: StorageOptions): Promise<Set<string>> {
|
async getCollapsedGroupings(options?: StorageOptions): Promise<string[]> {
|
||||||
return (await this.getAccount(this.reconcileOptions(options, this.defaultInMemoryOptions)))
|
return (
|
||||||
?.data?.collapsedGroupings;
|
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||||
|
)?.data?.collapsedGroupings;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setCollapsedGroupings(value: Set<string>, options?: StorageOptions): Promise<void> {
|
async setCollapsedGroupings(value: string[], options?: StorageOptions): Promise<void> {
|
||||||
const account = await this.getAccount(
|
const account = await this.getAccount(
|
||||||
this.reconcileOptions(options, this.defaultInMemoryOptions)
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
account.data.collapsedGroupings = value;
|
account.data.collapsedGroupings = value;
|
||||||
await this.saveAccount(account, this.reconcileOptions(options, this.defaultInMemoryOptions));
|
await this.saveAccount(
|
||||||
|
account,
|
||||||
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConvertAccountToKeyConnector(options?: StorageOptions): Promise<boolean> {
|
async getConvertAccountToKeyConnector(options?: StorageOptions): Promise<boolean> {
|
||||||
|
Loading…
Reference in New Issue
Block a user