1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-12 14:34:02 +00:00

[PM-15520] Move organizationPaymentStatus$ out of page setup flow and tweak it to avoid hanging when user is not an owner (#12224) (#12227)

(cherry picked from commit 2e53a645c9)
This commit is contained in:
Shane Melton
2024-12-03 13:22:05 -08:00
committed by GitHub
parent 74cccee360
commit 21754fde27
2 changed files with 34 additions and 35 deletions

View File

@@ -1,4 +1,6 @@
<app-vault-banners [organizationsPaymentStatus]="organizationsPaymentStatus"></app-vault-banners>
<app-vault-banners
[organizationsPaymentStatus]="organizationsPaymentStatus$ | async"
></app-vault-banners>
<app-vault-header
[filter]="filter"

View File

@@ -180,7 +180,6 @@ export class VaultComponent implements OnInit, OnDestroy {
protected canCreateCollections = false;
protected currentSearchText$: Observable<string>;
private activeUserId: UserId;
protected organizationsPaymentStatus: FreeTrial[] = [];
private searchText$ = new Subject<string>();
private refresh$ = new BehaviorSubject<void>(null);
private destroy$ = new Subject<void>();
@@ -208,6 +207,37 @@ export class VaultComponent implements OnInit, OnDestroy {
),
);
protected organizationsPaymentStatus$: Observable<FreeTrial[]> = combineLatest([
this.organizationService.organizations$.pipe(
map((organizations) => organizations?.filter((org) => org.isOwner) ?? []),
),
this.hasSubscription$,
]).pipe(
switchMap(([ownerOrgs, hasSubscription]) => {
if (!ownerOrgs || ownerOrgs.length === 0 || !hasSubscription) {
return of([]);
}
return combineLatest(
ownerOrgs.map((org) =>
combineLatest([
this.organizationApiService.getSubscription(org.id),
this.organizationApiService.getBilling(org.id),
]).pipe(
map(([subscription, billing]) => {
return this.trialFlowService.checkForOrgsWithUpcomingPaymentIssues(
org,
subscription,
billing?.paymentSource,
);
}),
),
),
);
}),
map((results) => results.filter((result) => result.shownBanner)),
shareReplay({ refCount: false, bufferSize: 1 }),
);
constructor(
private syncService: SyncService,
private route: ActivatedRoute,
@@ -423,36 +453,6 @@ export class VaultComponent implements OnInit, OnDestroy {
this.unpaidSubscriptionDialog$.pipe(takeUntil(this.destroy$)).subscribe();
const organizationsPaymentStatus$ = combineLatest([
this.organizationService.organizations$,
this.hasSubscription$,
]).pipe(
switchMap(([allOrganizations, hasSubscription]) => {
if (!allOrganizations || allOrganizations.length === 0 || !hasSubscription) {
return of([]);
}
return combineLatest(
allOrganizations
.filter((org) => org.isOwner && hasSubscription)
.map((org) =>
combineLatest([
this.organizationApiService.getSubscription(org.id),
this.organizationApiService.getBilling(org.id),
]).pipe(
map(([subscription, billing]) => {
return this.trialFlowService.checkForOrgsWithUpcomingPaymentIssues(
org,
subscription,
billing?.paymentSource,
);
}),
),
),
);
}),
map((results) => results.filter((result) => result.shownBanner)),
);
firstSetup$
.pipe(
switchMap(() => this.refresh$),
@@ -466,7 +466,6 @@ export class VaultComponent implements OnInit, OnDestroy {
ciphers$,
collections$,
selectedCollection$,
organizationsPaymentStatus$,
]),
),
takeUntil(this.destroy$),
@@ -480,7 +479,6 @@ export class VaultComponent implements OnInit, OnDestroy {
ciphers,
collections,
selectedCollection,
organizationsPaymentStatus,
]) => {
this.filter = filter;
this.canAccessPremium = canAccessPremium;
@@ -496,7 +494,6 @@ export class VaultComponent implements OnInit, OnDestroy {
this.showBulkMove = filter.type !== "trash";
this.isEmpty = collections?.length === 0 && ciphers?.length === 0;
this.organizationsPaymentStatus = organizationsPaymentStatus;
this.performingInitialLoad = false;
this.refreshing = false;
},