Show subscription status as active for premium if incomplete and within 15 seconds of creation (#11334)

This commit is contained in:
Alex Morask 2024-10-01 08:45:01 -04:00 committed by GitHub
parent 7108a34ac0
commit 2b78ac5151
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View File

@ -42,7 +42,7 @@
<dl> <dl>
<dt>{{ "status" | i18n }}</dt> <dt>{{ "status" | i18n }}</dt>
<dd> <dd>
<span class="tw-capitalize">{{ (subscription && subscription.status) || "-" }}</span> <span class="tw-capitalize">{{ (subscription && subscriptionStatus) || "-" }}</span>
<span bitBadge variant="warning" *ngIf="subscriptionMarkedForCancel">{{ <span bitBadge variant="warning" *ngIf="subscriptionMarkedForCancel">{{
"pendingCancellation" | i18n "pendingCancellation" | i18n
}}</span> }}</span>

View File

@ -35,8 +35,6 @@ import { UpdateLicenseDialogResult } from "../shared/update-license-types";
export class UserSubscriptionComponent implements OnInit { export class UserSubscriptionComponent implements OnInit {
loading = false; loading = false;
firstLoaded = false; firstLoaded = false;
adjustStorageAdd = true;
showUpdateLicense = false;
sub: SubscriptionResponse; sub: SubscriptionResponse;
selfHosted = false; selfHosted = false;
cloudWebVaultUrl: string; cloudWebVaultUrl: string;
@ -65,7 +63,7 @@ export class UserSubscriptionComponent implements OnInit {
private toastService: ToastService, private toastService: ToastService,
private configService: ConfigService, private configService: ConfigService,
) { ) {
this.selfHosted = platformUtilsService.isSelfHost(); this.selfHosted = this.platformUtilsService.isSelfHost();
} }
async ngOnInit() { async ngOnInit() {
@ -216,11 +214,28 @@ export class UserSubscriptionComponent implements OnInit {
: 0; : 0;
} }
get storageProgressWidth() {
return this.storagePercentage < 5 ? 5 : 0;
}
get title(): string { get title(): string {
return this.i18nService.t(this.selfHosted ? "subscription" : "premiumMembership"); return this.i18nService.t(this.selfHosted ? "subscription" : "premiumMembership");
} }
get subscriptionStatus(): string | null {
if (!this.subscription) {
return null;
} else {
/*
Premium users who sign up with PayPal will have their subscription activated by a webhook.
This is an arbitrary 15-second grace period where we show their subscription as active rather than
incomplete while we wait for our webhook to process the `invoice.created` event.
*/
if (this.subscription.status === "incomplete") {
const periodStartMS = new Date(this.subscription.periodStartDate).getTime();
const nowMS = new Date().getTime();
return nowMS - periodStartMS <= 15000
? this.i18nService.t("active")
: this.subscription.status;
}
return this.subscription.status;
}
}
} }