mirror of
https://github.com/bitwarden/browser
synced 2026-02-28 02:23:25 +00:00
Fix stale data issue in new login popout (#17307)
* Fix stale data issue in new login popout * Update the comments * Address critical claude code bot suggestions * Clean out all stale data from pop up * Fix cached cipher issue * Fix caching issue between tab and overlay flow * Address claude comments
This commit is contained in:
@@ -304,13 +304,30 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
* Updates `updatedCipherView` based on the value from the cache.
|
||||
*/
|
||||
setInitialCipherFromCache() {
|
||||
// If we are coming from the overlay/popup flow clear the cache to avoid old cached data
|
||||
const hasOverlayData =
|
||||
this.config.initialValues &&
|
||||
(this.config.initialValues.username !== undefined ||
|
||||
this.config.initialValues.password !== undefined);
|
||||
|
||||
if (hasOverlayData) {
|
||||
this.cipherFormCacheService.clearCache();
|
||||
return;
|
||||
}
|
||||
|
||||
const cachedCipher = this.cipherFormCacheService.getCachedCipherView();
|
||||
if (cachedCipher === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the cached cipher when it matches the cipher being edited
|
||||
if (this.updatedCipherView.id === cachedCipher.id) {
|
||||
const isEditingExistingCipher =
|
||||
this.updatedCipherView.id && this.updatedCipherView.id === cachedCipher.id;
|
||||
const isCreatingNewCipher =
|
||||
!this.updatedCipherView.id &&
|
||||
!cachedCipher.id &&
|
||||
this.updatedCipherView.type === cachedCipher.type;
|
||||
|
||||
if (isEditingExistingCipher || isCreatingNewCipher) {
|
||||
this.updatedCipherView = cachedCipher;
|
||||
}
|
||||
}
|
||||
@@ -382,6 +399,9 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
this.config,
|
||||
);
|
||||
|
||||
// Clear the cache after successful save
|
||||
this.cipherFormCacheService.clearCache();
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
title: null,
|
||||
|
||||
Reference in New Issue
Block a user