mirror of
https://github.com/bitwarden/browser
synced 2025-12-06 00:13:28 +00:00
[PM-23368] - [Defect] Browser - Autofill options disappear after vault sync and page refresh (#16590)
* skip cache updating when sync data hasn't changed * re-insert comment * check for diff in replace method * update comment
This commit is contained in:
@@ -1163,6 +1163,16 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async replace(ciphers: { [id: string]: CipherData }, userId: UserId): Promise<any> {
|
async replace(ciphers: { [id: string]: CipherData }, userId: UserId): Promise<any> {
|
||||||
|
const current = (await firstValueFrom(this.encryptedCiphersState(userId).state$)) ?? {};
|
||||||
|
|
||||||
|
// The extension relies on chrome.storage.StorageArea.onChanged to detect updates.
|
||||||
|
// If stored and provided data are identical, this event doesn’t fire and the ciphers$
|
||||||
|
// observable won’t emit a new value. In this case we can skip the update to avoid calling
|
||||||
|
// clearCache and causing an empty state.
|
||||||
|
if (JSON.stringify(current) === JSON.stringify(ciphers)) {
|
||||||
|
return ciphers;
|
||||||
|
}
|
||||||
|
|
||||||
await this.updateEncryptedCipherState(() => ciphers, userId);
|
await this.updateEncryptedCipherState(() => ciphers, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1176,13 +1186,16 @@ export class CipherService implements CipherServiceAbstraction {
|
|||||||
userId: UserId = null,
|
userId: UserId = null,
|
||||||
): Promise<Record<CipherId, CipherData>> {
|
): Promise<Record<CipherId, CipherData>> {
|
||||||
userId ||= await firstValueFrom(this.stateProvider.activeUserId$);
|
userId ||= await firstValueFrom(this.stateProvider.activeUserId$);
|
||||||
|
|
||||||
await this.clearCache(userId);
|
await this.clearCache(userId);
|
||||||
|
|
||||||
const updatedCiphers = await this.stateProvider
|
const updatedCiphers = await this.stateProvider
|
||||||
.getUser(userId, ENCRYPTED_CIPHERS)
|
.getUser(userId, ENCRYPTED_CIPHERS)
|
||||||
.update((current) => {
|
.update((current) => {
|
||||||
const result = update(current ?? {});
|
const result = update(current ?? {});
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Some state storage providers (e.g. Electron) don't update the state immediately, wait for next tick
|
// Some state storage providers (e.g. Electron) don't update the state immediately, wait for next tick
|
||||||
// Otherwise, subscribers to cipherViews$ can get stale data
|
// Otherwise, subscribers to cipherViews$ can get stale data
|
||||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|||||||
Reference in New Issue
Block a user