Skip to content

Commit d2518d4

Browse files
committed
add isTrial check for pro trial accounts
1 parent a7e446e commit d2518d4

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/plus/gk/account/subscription.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface SubscriptionPlan {
3434
readonly startedOn: string;
3535
readonly expiresOn?: string | undefined;
3636
readonly organizationId: string | undefined;
37+
readonly isTrial: boolean;
3738
}
3839

3940
export interface SubscriptionAccount {
@@ -143,6 +144,7 @@ export function getSubscriptionPlan(
143144
expiresOn?: Date,
144145
cancelled: boolean = false,
145146
nextTrialOptInDate?: string,
147+
isTrial: boolean = false,
146148
): SubscriptionPlan {
147149
return {
148150
id: id,
@@ -154,6 +156,7 @@ export function getSubscriptionPlan(
154156
nextTrialOptInDate: nextTrialOptInDate,
155157
startedOn: (startedOn ?? new Date()).toISOString(),
156158
expiresOn: expiresOn != null ? expiresOn.toISOString() : undefined,
159+
isTrial: isTrial,
157160
};
158161
}
159162

@@ -214,7 +217,7 @@ export function isSubscriptionExpired(subscription: Optional<Subscription, 'stat
214217
}
215218

216219
export function isSubscriptionTrial(subscription: Optional<Subscription, 'state'>): boolean {
217-
return subscription.plan.actual.id !== subscription.plan.effective.id;
220+
return subscription.plan.effective.isTrial;
218221
}
219222

220223
export function isSubscriptionInProTrial(subscription: Optional<Subscription, 'state'>): boolean {

src/plus/gk/account/subscriptionService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ export class SubscriptionService implements Disposable {
717717
...this._subscription,
718718
plan: {
719719
...this._subscription.plan,
720-
effective: getSubscriptionPlan(SubscriptionPlanId.Pro, false, 0, undefined, startedOn, expiresOn),
720+
effective: getSubscriptionPlan(SubscriptionPlanId.Pro, false, 0, undefined, startedOn, expiresOn, true),
721721
},
722722
previewTrial: previewTrial,
723723
});
@@ -1234,6 +1234,7 @@ export class SubscriptionService implements Disposable {
12341234
undefined,
12351235
new Date(subscription.previewTrial.startedOn),
12361236
new Date(subscription.previewTrial.expiresOn),
1237+
true,
12371238
),
12381239
},
12391240
};

src/plus/gk/checkin.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export function getSubscriptionFromCheckIn(
141141
license.organizationId,
142142
new Date(license.latestStartDate),
143143
new Date(license.latestEndDate),
144+
license.latestStatus === 'trial' || license.latestStatus === 'in_trial',
144145
);
145146
}
146147

@@ -177,6 +178,7 @@ export function getSubscriptionFromCheckIn(
177178
new Date(license.latestEndDate),
178179
license.latestStatus === 'cancelled',
179180
license.nextOptInDate ?? data.nextOptInDate,
181+
license.latestStatus === 'trial' || license.latestStatus === 'in_trial',
180182
);
181183
}
182184

0 commit comments

Comments
 (0)