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:
@@ -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";
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -35,6 +35,10 @@ export class LocalBackedSessionStorageService extends AbstractMemoryStorageServi
|
||||
super();
|
||||
}
|
||||
|
||||
get valuesRequireDeserialization(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
get updates$() {
|
||||
return this.updatesSubject.asObservable();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user