1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 09:13:33 +00:00

Fix SingleUserStateProvider (#7593)

* Fix SingleUserStateProvider

- Fix cache key to be unique per instance per user

* Add Specific State Provider Tests

* Add Missing await
This commit is contained in:
Justin Baur
2024-01-18 13:02:30 -05:00
committed by GitHub
parent 5810b0c7a2
commit 57609737f1
4 changed files with 152 additions and 4 deletions

View File

@@ -148,11 +148,13 @@ export class KeyDefinition<T> {
*/
buildCacheKey(scope: "user" | "global", userId?: "active" | UserId): string {
if (scope === "user" && userId == null) {
throw new Error("You must provide a userId when building a user scoped cache key.");
throw new Error(
"You must provide a userId or 'active' when building a user scoped cache key.",
);
}
return userId === null
? `${this.stateDefinition.storageLocation}_${scope}_${userId}_${this.stateDefinition.name}_${this.key}`
: `${this.stateDefinition.storageLocation}_${scope}_${this.stateDefinition.name}_${this.key}`;
? `${this.stateDefinition.storageLocation}_${scope}_${this.stateDefinition.name}_${this.key}`
: `${this.stateDefinition.storageLocation}_${scope}_${userId}_${this.stateDefinition.name}_${this.key}`;
}
private get errorKeyName() {