1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 07:13:32 +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:
Matt Gibson
2023-11-16 14:15:34 -05:00
committed by GitHub
parent bb46907951
commit 29aabeb4f5
25 changed files with 761 additions and 171 deletions

View File

@@ -1,4 +1,4 @@
import { awaitAsync } from "@bitwarden/angular/../test-utils";
import { awaitAsync } from "@bitwarden/common/../spec/utils";
import { mock, MockProxy } from "jest-mock-extended";
import { BehaviorSubject, ReplaySubject } from "rxjs";

View File

@@ -11,6 +11,9 @@ import { fromChromeEvent } from "../../browser/from-chrome-event";
export default abstract class AbstractChromeStorageService implements AbstractStorageService {
constructor(protected chromeStorageApi: chrome.storage.StorageArea) {}
get valuesRequireDeserialization(): boolean {
return true;
}
get updates$(): Observable<StorageUpdate> {
return fromChromeEvent(this.chromeStorageApi.onChanged).pipe(
mergeMap(([changes]) => {
@@ -27,7 +30,6 @@ export default abstract class AbstractChromeStorageService implements AbstractSt
key: key,
// For removes this property will not exist but then it will just be
// undefined which is fine.
value: change.newValue,
updateType: updateType,
};
});

View File

@@ -35,6 +35,10 @@ export class LocalBackedSessionStorageService extends AbstractMemoryStorageServi
super();
}
get valuesRequireDeserialization(): boolean {
return true;
}
get updates$() {
return this.updatesSubject.asObservable();
}