From 38f193ee6c4d28529a999c57d60fa99794ba28a0 Mon Sep 17 00:00:00 2001 From: Jonas Hendrickx Date: Mon, 7 Apr 2025 17:00:19 +0200 Subject: [PATCH] =?UTF-8?q?[PM-19713][BEEEP]=20Improve=20performance=20of?= =?UTF-8?q?=20whether=20user=20can=20view=20subsc=E2=80=A6=20(#14062)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../billing-account-profile-state.service.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libs/common/src/billing/services/account/billing-account-profile-state.service.ts b/libs/common/src/billing/services/account/billing-account-profile-state.service.ts index 155ce1493b4..efb22086075 100644 --- a/libs/common/src/billing/services/account/billing-account-profile-state.service.ts +++ b/libs/common/src/billing/services/account/billing-account-profile-state.service.ts @@ -68,15 +68,18 @@ export class DefaultBillingAccountProfileStateService implements BillingAccountP this.hasPremiumFromAnyOrganization$(userId), ]).pipe( concatMap(async ([hasPremiumPersonally, hasPremiumFromOrg]) => { - const isCloud = !this.platformUtilsService.isSelfHost(); - - let billing = null; - if (isCloud) { - billing = await this.apiService.getUserBillingHistory(); + if (hasPremiumPersonally === true || !hasPremiumFromOrg === true) { + return true; } - const cloudAndBillingHistory = isCloud && !billing?.hasNoHistory; - return hasPremiumPersonally || !hasPremiumFromOrg || cloudAndBillingHistory; + const isCloud = !this.platformUtilsService.isSelfHost(); + + if (isCloud) { + const billing = await this.apiService.getUserBillingHistory(); + return !billing?.hasNoHistory; + } + + return false; }), ); }