Bladeren bron

Fixes graph subscription access

- avoids mutating subscriptions

Co-authored-by: Eric Amodio <eamodio@gmail.com>
main
Keith Daulton 2 jaren geleden
bovenliggende
commit
faea28a390
2 gewijzigde bestanden met toevoegingen van 33 en 8 verwijderingen
  1. +15
    -2
      src/git/gitProviderService.ts
  2. +18
    -6
      src/plus/subscription/subscriptionService.ts

+ 15
- 2
src/git/gitProviderService.ts Bestand weergeven

@ -24,7 +24,12 @@ import type { SubscriptionChangeEvent } from '../plus/subscription/subscriptionS
import type { RepoComparisonKey } from '../repositories';
import { asRepoComparisonKey, Repositories } from '../repositories';
import type { FreeSubscriptionPlans, RequiredSubscriptionPlans, Subscription } from '../subscription';
import { getSubscriptionPlanPriority, isSubscriptionPaidPlan, SubscriptionPlanId } from '../subscription';
import {
getSubscriptionPlan,
getSubscriptionPlanPriority,
isSubscriptionPaidPlan,
SubscriptionPlanId,
} from '../subscription';
import { groupByFilterMap, groupByMap } from '../system/array';
import { gate } from '../system/decorators/gate';
import { debug, getLogScope, log } from '../system/decorators/log';
@ -543,7 +548,15 @@ export class GitProviderService implements Disposable {
access.visibility === RepositoryVisibility.Private &&
access.subscription.current.previewTrial == null
),
subscription: { current: access.subscription.current },
subscription: {
current: {
...access.subscription.current,
plan: {
...access.subscription.current.plan,
effective: getSubscriptionPlan(SubscriptionPlanId.Pro, undefined),
},
},
},
visibility: access.visibility,
};
}

+ 18
- 6
src/plus/subscription/subscriptionService.ts Bestand weergeven

@ -776,16 +776,28 @@ 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) {
(subscription.plan as PickMutable<Subscription['plan'], 'effective'>).effective = getSubscriptionPlan(
SubscriptionPlanId.Pro,
new Date(subscription.previewTrial.startedOn),
new Date(subscription.previewTrial.expiresOn),
);
subscription = {
...subscription,
plan: {
...subscription.plan,
effective: getSubscriptionPlan(
SubscriptionPlanId.Pro,
new Date(subscription.previewTrial.startedOn),
new Date(subscription.previewTrial.expiresOn),
),
},
};
}
// If the effective plan has expired, then replace it with the actual plan
if (isSubscriptionExpired(subscription)) {
(subscription.plan as PickMutable<Subscription['plan'], 'effective'>).effective = subscription.plan.actual;
subscription = {
...subscription,
plan: {
...subscription.plan,
effective: subscription.plan.actual,
},
};
}
subscription.state = computeSubscriptionState(subscription);

Laden…
Annuleren
Opslaan