1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

[PM-26681] - ensure initial cipher state is set for empty vaults (#16793)

* don't skip cipher state updates for empty vaults

* add specs and comment

* do not return ciphers, just return

* update spec names
This commit is contained in:
Jordan Aasen
2025-10-08 14:13:59 -07:00
committed by GitHub
parent 2aa0ad672e
commit 46aa3866df
2 changed files with 88 additions and 2 deletions

View File

@@ -1169,8 +1169,10 @@ export class CipherService implements CipherServiceAbstraction {
// If stored and provided data are identical, this event doesnt fire and the ciphers$
// observable wont 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;
// If the current state is empty (eg. for new users), we still want to perform the update to ensure
// we trigger an emission as many subscribers rely on it during initialization.
if (Object.keys(current).length > 0 && JSON.stringify(current) === JSON.stringify(ciphers)) {
return;
}
await this.updateEncryptedCipherState(() => ciphers, userId);