mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
[PM-11249] Sync attachment updates across platforms (#11758)
* update extension refresh form when an attachment is added or removed - This is needed because the revision date was updated on the server and the locally stored cipher needs to match. * receive updated cipher from delete attachment endpoint - deleting an attachment will now alter the revision timestamp on a cipher. * patch the cipher when an attachment is added or deleted * migrate vault component to use the `cipherViews$` observable * reference `cipherViews$` on desktop for vault-items - This avoid race conditions where ciphers are cleared out in the background. `cipherViews` should always emit the latest views * return CipherData from cipher service so that consumers have the updated cipher right away * use the updated cipher from attachment endpoints to refresh the details within the add/edit components on desktop
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
OnInit,
|
||||
Output,
|
||||
} from "@angular/core";
|
||||
import { firstValueFrom, map, Observable } from "rxjs";
|
||||
import { filter, firstValueFrom, map, Observable } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
|
||||
@@ -144,11 +144,15 @@ export class ViewComponent implements OnDestroy, OnInit {
|
||||
async load() {
|
||||
this.cleanUp();
|
||||
|
||||
const cipher = await this.cipherService.get(this.cipherId);
|
||||
const activeUserId = await firstValueFrom(this.activeUserId$);
|
||||
this.cipher = await cipher.decrypt(
|
||||
await this.cipherService.getKeyForCipherKeyDecryption(cipher, activeUserId),
|
||||
// Grab individual cipher from `cipherViews$` for the most up-to-date information
|
||||
this.cipher = await firstValueFrom(
|
||||
this.cipherService.cipherViews$.pipe(
|
||||
map((ciphers) => ciphers.find((c) => c.id === this.cipherId)),
|
||||
filter((cipher) => !!cipher),
|
||||
),
|
||||
);
|
||||
|
||||
this.canAccessPremium = await firstValueFrom(
|
||||
this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeUserId),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user