Przeglądaj źródła

Fixes issue w/ preview trial "winning" over paid

main
Eric Amodio 1 rok temu
rodzic
commit
f411bb2676
1 zmienionych plików z 16 dodań i 12 usunięć
  1. +16
    -12
      src/plus/subscription/subscriptionService.ts

+ 16
- 12
src/plus/subscription/subscriptionService.ts Wyświetl plik

@ -846,30 +846,34 @@ export class SubscriptionService implements Disposable {
};
}
// Check if the preview has expired, if not apply it
if (subscription.previewTrial != null && (getTimeRemaining(subscription.previewTrial.expiresOn) ?? 0) > 0) {
// If the effective plan has expired, then replace it with the actual plan
if (isSubscriptionExpired(subscription)) {
subscription = {
...subscription,
plan: {
...subscription.plan,
effective: getSubscriptionPlan(
SubscriptionPlanId.Pro,
false,
undefined,
new Date(subscription.previewTrial.startedOn),
new Date(subscription.previewTrial.expiresOn),
),
effective: subscription.plan.actual,
},
};
}
// If the effective plan has expired, then replace it with the actual plan
if (isSubscriptionExpired(subscription)) {
// If we don't have a paid plan (or a non-preview trial), check if the preview trial has expired, if not apply it
if (
!isSubscriptionPaid(subscription) &&
subscription.previewTrial != null &&
(getTimeRemaining(subscription.previewTrial.expiresOn) ?? 0) > 0
) {
subscription = {
...subscription,
plan: {
...subscription.plan,
effective: subscription.plan.actual,
effective: getSubscriptionPlan(
SubscriptionPlanId.Pro,
false,
undefined,
new Date(subscription.previewTrial.startedOn),
new Date(subscription.previewTrial.expiresOn),
),
},
};
}

Ładowanie…
Anuluj
Zapisz