Pārlūkot izejas kodu

Fixes issue w/ preview trial "winning" over paid

main
Eric Amodio pirms 1 gada
vecāks
revīzija
f411bb2676
1 mainītis faili ar 16 papildinājumiem un 12 dzēšanām
  1. +16
    -12
      src/plus/subscription/subscriptionService.ts

+ 16
- 12
src/plus/subscription/subscriptionService.ts Parādīt failu

@ -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),
),
},
};
}

Notiek ielāde…
Atcelt
Saglabāt