Skip to content

Commit

Permalink
[PM-18055] - sync list and item view after saving vault item (#13412)
Browse files Browse the repository at this point in the history
* sync list and item view after saving vault item

* sync folder on save

* remove unused destroy ref
  • Loading branch information
jaasen-livefront authored Feb 18, 2025
1 parent 6e4a06d commit 993c056
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
13 changes: 8 additions & 5 deletions apps/desktop/src/vault/app/vault/vault.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SyncService } from "@bitwarden/common/platform/sync";
import { CipherId } from "@bitwarden/common/types/guid";
import { CipherId, UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
import { CipherType } from "@bitwarden/common/vault/enums";
Expand Down Expand Up @@ -90,6 +90,7 @@ export class VaultComponent implements OnInit, OnDestroy {
deleted = false;
userHasPremiumAccess = false;
activeFilter: VaultFilter = new VaultFilter();
activeUserId: UserId;

private modal: ModalRef = null;
private componentIsDestroyed$ = new Subject<boolean>();
Expand Down Expand Up @@ -237,12 +238,12 @@ export class VaultComponent implements OnInit, OnDestroy {
});
}

const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
this.activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));

this.cipherService
.failedToDecryptCiphers$(activeUserId)
.failedToDecryptCiphers$(this.activeUserId)
.pipe(
map((ciphers) => ciphers.filter((c) => !c.isDeleted)),
map((ciphers) => ciphers?.filter((c) => !c.isDeleted) ?? []),
filter((ciphers) => ciphers.length > 0),
take(1),
takeUntil(this.componentIsDestroyed$),
Expand Down Expand Up @@ -494,8 +495,10 @@ export class VaultComponent implements OnInit, OnDestroy {
async savedCipher(cipher: CipherView) {
this.cipherId = cipher.id;
this.action = "view";
this.go();
await this.vaultItemsComponent.refresh();
await this.cipherService.clearCache(this.activeUserId);
await this.viewComponent.load();
this.go();
}

async deletedCipher(cipher: CipherView) {
Expand Down
19 changes: 6 additions & 13 deletions libs/angular/src/vault/components/view.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
OnInit,
Output,
} from "@angular/core";
import { filter, firstValueFrom, map, Observable, Subject, takeUntil } 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";
Expand Down Expand Up @@ -80,8 +80,6 @@ export class ViewComponent implements OnDestroy, OnInit {
private previousCipherId: string;
private passwordReprompted = false;

private destroyed$ = new Subject<void>();

get fido2CredentialCreationDateValue(): string {
const dateCreated = this.i18nService.t("dateCreated");
const creationDate = this.datePipe.transform(
Expand Down Expand Up @@ -144,18 +142,14 @@ export class ViewComponent implements OnDestroy, OnInit {
async load() {
this.cleanUp();

const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
// Grab individual cipher from `cipherViews$` for the most up-to-date information
this.cipherService
.cipherViews$(activeUserId)
.pipe(
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
this.cipher = await firstValueFrom(
this.cipherService.cipherViews$(activeUserId).pipe(
map((ciphers) => ciphers?.find((c) => c.id === this.cipherId)),
filter((cipher) => !!cipher),
takeUntil(this.destroyed$),
)
.subscribe((cipher) => {
this.cipher = cipher;
});
),
);

this.canAccessPremium = await firstValueFrom(
this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeUserId),
Expand Down Expand Up @@ -528,7 +522,6 @@ export class ViewComponent implements OnDestroy, OnInit {
this.showCardNumber = false;
this.showCardCode = false;
this.passwordReprompted = false;
this.destroyed$.next();
if (this.totpInterval) {
clearInterval(this.totpInterval);
}
Expand Down

0 comments on commit 993c056

Please sign in to comment.