Skip to content

Commit 677526d

Browse files
committed
remove expired licenses filter & check actual license expiration
1 parent 713ad28 commit 677526d

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/plus/gk/checkin.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import type { Organization } from './account/organization';
22
import type { Subscription } from './account/subscription';
33
import {
4-
computeSubscriptionState,
54
getSubscriptionPlan,
65
getSubscriptionPlanPriority,
6+
isSubscriptionExpired,
77
SubscriptionPlanId,
8-
SubscriptionState,
98
} from './account/subscription';
109

1110
export interface GKCheckInResponse {
@@ -72,7 +71,6 @@ export function getSubscriptionFromCheckIn(
7271

7372
let effectiveLicenses = Object.entries(data.licenses.effectiveLicenses) as [GKLicenseType, GKLicense][];
7473
let paidLicenses = Object.entries(data.licenses.paidLicenses) as [GKLicenseType, GKLicense][];
75-
paidLicenses = paidLicenses.filter(license => license[1].latestStatus !== 'cancelled');
7674
if (paidLicenses.length > 1) {
7775
paidLicenses.sort(
7876
(a, b) =>
@@ -82,6 +80,7 @@ export function getSubscriptionFromCheckIn(
8280
licenseStatusPriority(a[1].latestStatus)),
8381
);
8482
}
83+
8584
if (effectiveLicenses.length > 1) {
8685
effectiveLicenses.sort(
8786
(a, b) =>
@@ -180,17 +179,10 @@ export function getSubscriptionFromCheckIn(
180179
);
181180
}
182181

183-
const isActualLicenseExpired =
184-
computeSubscriptionState({
185-
plan: {
186-
actual: actual,
187-
effective: actual,
188-
},
189-
account: account,
190-
}) === SubscriptionState.PaidExpired;
191182
if (
192183
effective == null ||
193-
(getSubscriptionPlanPriority(actual.id) >= getSubscriptionPlanPriority(effective.id) && !isActualLicenseExpired)
184+
(getSubscriptionPlanPriority(actual.id) >= getSubscriptionPlanPriority(effective.id) &&
185+
!isSubscriptionExpired(actual))
194186
) {
195187
effective = { ...actual };
196188
}

0 commit comments

Comments
 (0)