mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
Ps/pm 2910/state framework improvements (#6860)
* Allow for update logic in state update callbacks * Prefer reading updates to sending in stream * Inform state providers when they must deserialize * Update DefaultGlobalState to act more like DefaultUserState * Fully Implement AbstractStorageService * Add KeyDefinitionOptions * Address PR feedback * More Descriptive Error --------- Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
This commit is contained in:
@@ -107,6 +107,9 @@ export class LowdbStorageService implements AbstractStorageService {
|
||||
this.ready = true;
|
||||
}
|
||||
|
||||
get valuesRequireDeserialization(): boolean {
|
||||
return true;
|
||||
}
|
||||
get updates$() {
|
||||
return this.updatesSubject.asObservable();
|
||||
}
|
||||
@@ -133,7 +136,7 @@ export class LowdbStorageService implements AbstractStorageService {
|
||||
return this.lockDbFile(() => {
|
||||
this.readForNoCache();
|
||||
this.db.set(key, obj).write();
|
||||
this.updatesSubject.next({ key, value: obj, updateType: "save" });
|
||||
this.updatesSubject.next({ key, updateType: "save" });
|
||||
this.logService.debug(`Successfully wrote ${key} to db`);
|
||||
return;
|
||||
});
|
||||
@@ -144,7 +147,7 @@ export class LowdbStorageService implements AbstractStorageService {
|
||||
return this.lockDbFile(() => {
|
||||
this.readForNoCache();
|
||||
this.db.unset(key).write();
|
||||
this.updatesSubject.next({ key, value: null, updateType: "remove" });
|
||||
this.updatesSubject.next({ key, updateType: "remove" });
|
||||
this.logService.debug(`Successfully removed ${key} from db`);
|
||||
return;
|
||||
});
|
||||
|
||||
@@ -14,6 +14,10 @@ export class NodeEnvSecureStorageService implements AbstractStorageService {
|
||||
private cryptoService: () => CryptoService
|
||||
) {}
|
||||
|
||||
get valuesRequireDeserialization(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
get updates$() {
|
||||
return throwError(
|
||||
() => new Error("Secure storage implementations cannot have their updates subscribed to.")
|
||||
|
||||
Reference in New Issue
Block a user