mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-9111] Extension: persist add/edit form (#12236)
* remove todo * Retrieve cache cipher for add-edit form * user prefilled cipher for add-edit form * add listener for clearing view cache * clear local cache when clearing global state * track initial value of cache for down stream logic that should only occur on non-cached values * add feature flag for edit form persistence * add tests for cipher form cache service * fix optional initialValues * add services to cipher form storybook * fix strict types * rename variables to be platform agnostic * use deconstructed collectionIds variable to avoid them be overwritten * use the originalCipherView for initial values * add comment about signal equality * prevent events from being emitted when adding uris to the existing form - This stops other values from being overwrote in the initialization process * add check for cached cipher when adding initial uris
This commit is contained in:
@@ -133,6 +133,7 @@ export class PopupViewCacheService implements ViewCacheService {
|
||||
}
|
||||
|
||||
private clearState() {
|
||||
this._cache = {}; // clear local cache
|
||||
this.messageSender.send(ClEAR_VIEW_CACHE_COMMAND, {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,13 +196,15 @@ describe("popup view cache", () => {
|
||||
});
|
||||
|
||||
it("should clear on 2nd navigation", async () => {
|
||||
await initServiceWithState({});
|
||||
await initServiceWithState({ temp: "state" });
|
||||
|
||||
await router.navigate(["a"]);
|
||||
expect(messageSenderMock.send).toHaveBeenCalledTimes(0);
|
||||
expect(service["_cache"]).toEqual({ temp: "state" });
|
||||
|
||||
await router.navigate(["b"]);
|
||||
expect(messageSenderMock.send).toHaveBeenCalledWith(ClEAR_VIEW_CACHE_COMMAND, {});
|
||||
expect(service["_cache"]).toEqual({});
|
||||
});
|
||||
|
||||
it("should ignore cached values when feature flag is off", async () => {
|
||||
|
||||
@@ -60,6 +60,11 @@ export class PopupViewCacheBackgroundService {
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
this.messageListener
|
||||
.messages$(ClEAR_VIEW_CACHE_COMMAND)
|
||||
.pipe(concatMap(() => this.popupViewCacheState.update(() => null)))
|
||||
.subscribe();
|
||||
|
||||
merge(
|
||||
// on tab changed, excluding extension tabs
|
||||
fromChromeEvent(chrome.tabs.onActivated).pipe(
|
||||
|
||||
Reference in New Issue
Block a user