1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-24 16:43:27 +00:00

[PM-29262] - improve performance of premium spotlight observable (#18490)

* improve performance of premium spotlight observable

* re-add comment

* fix test. remove unused service
This commit is contained in:
Jordan Aasen
2026-01-29 09:33:08 -08:00
committed by GitHub
parent b8bed69b23
commit 7b0957ab5e
3 changed files with 35 additions and 49 deletions

View File

@@ -1,8 +1,8 @@
import { inject, Injectable } from "@angular/core";
import { combineLatest, from, Observable, of, switchMap } from "rxjs";
import { catchError } from "rxjs/operators";
import { combineLatest, Observable, of, switchMap } from "rxjs";
import { catchError, map } from "rxjs/operators";
import { VaultProfileService } from "@bitwarden/angular/vault/services/vault-profile.service";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
@@ -20,11 +20,14 @@ const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
})
export class HasItemsNudgeService extends DefaultSingleNudgeService {
cipherService = inject(CipherService);
vaultProfileService = inject(VaultProfileService);
accountService = inject(AccountService);
logService = inject(LogService);
nudgeStatus$(nudgeType: NudgeType, userId: UserId): Observable<NudgeStatus> {
const profileDate$ = from(this.vaultProfileService.getProfileCreationDate(userId)).pipe(
const profileDate$ = this.accountService.activeAccount$.pipe(
map((account) => {
return account?.creationDate ?? new Date();
}),
catchError(() => {
this.logService.error("Error getting profile creation date");
// Default to today to ensure we show the nudge