Skip to content

Commit a7e446e

Browse files
committed
remove expired licenses filter & check actual license expiration
1 parent 294cdb5 commit a7e446e

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
@@ -2,11 +2,10 @@ import { SubscriptionPlanId } from '../../constants.subscription';
22
import type { Organization } from './account/organization';
33
import type { Subscription } from './account/subscription';
44
import {
5-
computeSubscriptionState,
65
getSubscriptionPlan,
76
getSubscriptionPlanPriority,
7+
isSubscriptionExpired,
88
SubscriptionPlanId,
9-
SubscriptionState,
109
} from './account/subscription';
1110

1211
export interface GKCheckInResponse {
@@ -73,7 +72,6 @@ export function getSubscriptionFromCheckIn(
7372

7473
let effectiveLicenses = Object.entries(data.licenses.effectiveLicenses) as [GKLicenseType, GKLicense][];
7574
let paidLicenses = Object.entries(data.licenses.paidLicenses) as [GKLicenseType, GKLicense][];
76-
paidLicenses = paidLicenses.filter(license => license[1].latestStatus !== 'cancelled');
7775
if (paidLicenses.length > 1) {
7876
paidLicenses.sort(
7977
(a, b) =>
@@ -83,6 +81,7 @@ export function getSubscriptionFromCheckIn(
8381
licenseStatusPriority(a[1].latestStatus)),
8482
);
8583
}
84+
8685
if (effectiveLicenses.length > 1) {
8786
effectiveLicenses.sort(
8887
(a, b) =>
@@ -181,17 +180,10 @@ export function getSubscriptionFromCheckIn(
181180
);
182181
}
183182

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

0 commit comments

Comments
 (0)