Skip to content

Commit 4a63648

Browse files
committed
add isTrial check for pro trial accounts
1 parent ff61804 commit 4a63648

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
@@ -41,6 +41,7 @@ export interface SubscriptionPlan {
4141
readonly startedOn: string;
4242
readonly expiresOn?: string | undefined;
4343
readonly organizationId: string | undefined;
44+
readonly isTrial: boolean;
4445
}
4546

4647
export interface SubscriptionAccount {
@@ -173,6 +174,7 @@ export function getSubscriptionPlan(
173174
expiresOn?: Date,
174175
cancelled: boolean = false,
175176
nextTrialOptInDate?: string,
177+
isTrial: boolean = false,
176178
): SubscriptionPlan {
177179
return {
178180
id: id,
@@ -184,6 +186,7 @@ export function getSubscriptionPlan(
184186
nextTrialOptInDate: nextTrialOptInDate,
185187
startedOn: (startedOn ?? new Date()).toISOString(),
186188
expiresOn: expiresOn != null ? expiresOn.toISOString() : undefined,
189+
isTrial: isTrial,
187190
};
188191
}
189192

@@ -244,7 +247,7 @@ export function isSubscriptionExpired(subscription: Optional<Subscription, 'stat
244247
}
245248

246249
export function isSubscriptionTrial(subscription: Optional<Subscription, 'state'>): boolean {
247-
return subscription.plan.actual.id !== subscription.plan.effective.id;
250+
return subscription.plan.effective.isTrial;
248251
}
249252

250253
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
@@ -718,7 +718,7 @@ export class SubscriptionService implements Disposable {
718718
...this._subscription,
719719
plan: {
720720
...this._subscription.plan,
721-
effective: getSubscriptionPlan(SubscriptionPlanId.Pro, false, 0, undefined, startedOn, expiresOn),
721+
effective: getSubscriptionPlan(SubscriptionPlanId.Pro, false, 0, undefined, startedOn, expiresOn, true),
722722
},
723723
previewTrial: previewTrial,
724724
});
@@ -1233,6 +1233,7 @@ export class SubscriptionService implements Disposable {
12331233
undefined,
12341234
new Date(subscription.previewTrial.startedOn),
12351235
new Date(subscription.previewTrial.expiresOn),
1236+
true,
12361237
),
12371238
},
12381239
};

src/plus/gk/checkin.ts

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

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

0 commit comments

Comments
 (0)