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:
@@ -1169,8 +1169,10 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
// 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;
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user