1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 13:23:34 +00:00

[PM-18055] - sync list and item view after saving vault item (#13412)

* sync list and item view after saving vault item

* sync folder on save

* remove unused destroy ref
This commit is contained in:
Jordan Aasen
2025-02-18 12:41:42 -08:00
committed by GitHub
parent 6e4a06dab4
commit 993c056b19
2 changed files with 14 additions and 18 deletions

View File

@@ -28,7 +28,7 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SyncService } from "@bitwarden/common/platform/sync"; 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 { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service"; import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
import { CipherType } from "@bitwarden/common/vault/enums"; import { CipherType } from "@bitwarden/common/vault/enums";
@@ -90,6 +90,7 @@ export class VaultComponent implements OnInit, OnDestroy {
deleted = false; deleted = false;
userHasPremiumAccess = false; userHasPremiumAccess = false;
activeFilter: VaultFilter = new VaultFilter(); activeFilter: VaultFilter = new VaultFilter();
activeUserId: UserId;
private modal: ModalRef = null; private modal: ModalRef = null;
private componentIsDestroyed$ = new Subject<boolean>(); private componentIsDestroyed$ = new Subject<boolean>();
@@ -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 this.cipherService
.failedToDecryptCiphers$(activeUserId) .failedToDecryptCiphers$(this.activeUserId)
.pipe( .pipe(
map((ciphers) => ciphers.filter((c) => !c.isDeleted)), map((ciphers) => ciphers?.filter((c) => !c.isDeleted) ?? []),
filter((ciphers) => ciphers.length > 0), filter((ciphers) => ciphers.length > 0),
take(1), take(1),
takeUntil(this.componentIsDestroyed$), takeUntil(this.componentIsDestroyed$),
@@ -494,8 +495,10 @@ export class VaultComponent implements OnInit, OnDestroy {
async savedCipher(cipher: CipherView) { async savedCipher(cipher: CipherView) {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = "view"; this.action = "view";
this.go();
await this.vaultItemsComponent.refresh(); await this.vaultItemsComponent.refresh();
await this.cipherService.clearCache(this.activeUserId);
await this.viewComponent.load();
this.go();
} }
async deletedCipher(cipher: CipherView) { async deletedCipher(cipher: CipherView) {

View File

@@ -11,7 +11,7 @@ import {
OnInit, OnInit,
Output, Output,
} from "@angular/core"; } 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 { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service"; import { AuditService } from "@bitwarden/common/abstractions/audit.service";
@@ -80,8 +80,6 @@ export class ViewComponent implements OnDestroy, OnInit {
private previousCipherId: string; private previousCipherId: string;
private passwordReprompted = false; private passwordReprompted = false;
private destroyed$ = new Subject<void>();
get fido2CredentialCreationDateValue(): string { get fido2CredentialCreationDateValue(): string {
const dateCreated = this.i18nService.t("dateCreated"); const dateCreated = this.i18nService.t("dateCreated");
const creationDate = this.datePipe.transform( const creationDate = this.datePipe.transform(
@@ -144,18 +142,14 @@ export class ViewComponent implements OnDestroy, OnInit {
async load() { async load() {
this.cleanUp(); this.cleanUp();
const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
// Grab individual cipher from `cipherViews$` for the most up-to-date information // Grab individual cipher from `cipherViews$` for the most up-to-date information
this.cipherService const activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId));
.cipherViews$(activeUserId) this.cipher = await firstValueFrom(
.pipe( this.cipherService.cipherViews$(activeUserId).pipe(
map((ciphers) => ciphers?.find((c) => c.id === this.cipherId)), map((ciphers) => ciphers?.find((c) => c.id === this.cipherId)),
filter((cipher) => !!cipher), filter((cipher) => !!cipher),
takeUntil(this.destroyed$), ),
) );
.subscribe((cipher) => {
this.cipher = cipher;
});
this.canAccessPremium = await firstValueFrom( this.canAccessPremium = await firstValueFrom(
this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeUserId), this.billingAccountProfileStateService.hasPremiumFromAnySource$(activeUserId),
@@ -528,7 +522,6 @@ export class ViewComponent implements OnDestroy, OnInit {
this.showCardNumber = false; this.showCardNumber = false;
this.showCardCode = false; this.showCardCode = false;
this.passwordReprompted = false; this.passwordReprompted = false;
this.destroyed$.next();
if (this.totpInterval) { if (this.totpInterval) {
clearInterval(this.totpInterval); clearInterval(this.totpInterval);
} }