mirror of
https://github.com/bitwarden/browser
synced 2026-02-24 08:33:29 +00:00
[PM-32341] use an initial cache value in default cipher form (#19091)
* update default cipher form cache with initial cache value
This commit is contained in:
@@ -18,6 +18,12 @@ export class CipherFormCacheService {
|
||||
*/
|
||||
initializedWithValue: boolean;
|
||||
|
||||
/**
|
||||
* The cipher form will overwrite the cache from various components when initialized
|
||||
* To prevent this, we store the initial value of the cache when the service is initialized
|
||||
*/
|
||||
initialCacheValue: CipherView | null;
|
||||
|
||||
private cipherCache = this.viewCacheService.signal<CipherView | null>({
|
||||
key: CIPHER_FORM_CACHE_KEY,
|
||||
initialValue: null,
|
||||
@@ -26,6 +32,7 @@ export class CipherFormCacheService {
|
||||
|
||||
constructor() {
|
||||
this.initializedWithValue = !!this.cipherCache();
|
||||
this.initialCacheValue = this.cipherCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,13 +49,14 @@ export class CipherFormCacheService {
|
||||
* Returns the cached CipherView when available.
|
||||
*/
|
||||
getCachedCipherView(): CipherView | null {
|
||||
return this.cipherCache();
|
||||
return this.initialCacheValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the cached CipherView.
|
||||
*/
|
||||
clearCache(): void {
|
||||
this.initialCacheValue = null;
|
||||
this.cipherCache.set(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user