From 4950027b10958d094f4e0d5774ce7145820ce7dd Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Thu, 25 Aug 2022 15:23:59 -0400 Subject: [PATCH] Fixes graph gating --- src/git/gitProviderService.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/git/gitProviderService.ts b/src/git/gitProviderService.ts index c059988..d65f795 100644 --- a/src/git/gitProviderService.ts +++ b/src/git/gitProviderService.ts @@ -520,11 +520,25 @@ export class GitProviderService implements Disposable { cacheKey = path; } - let access = this._accessCache.get(cacheKey); - if (access == null) { - access = this.accessCore(feature, repoPath); - this._accessCache.set(cacheKey, access); + let accessPromise = this._accessCache.get(cacheKey); + if (accessPromise == null) { + accessPromise = this.accessCore(feature, repoPath); + this._accessCache.set(cacheKey, accessPromise); } + + const access = await accessPromise; + if ( + feature === PlusFeatures.Graph && + access.visibility !== RepositoryVisibility.Private && + access.subscription.current.plan.effective.id === SubscriptionPlanId.Free + ) { + return { + allowed: true, + subscription: { current: access.subscription.current }, + visibility: access.visibility, + }; + } + return access; } @@ -554,14 +568,6 @@ export class GitProviderService implements Disposable { if (visibility !== RepositoryVisibility.Private) { switch (plan) { case SubscriptionPlanId.Free: - if (feature === PlusFeatures.Graph) { - return { - allowed: true, - subscription: { current: subscription }, - visibility: visibility, - }; - } - return { allowed: false, subscription: { current: subscription, required: SubscriptionPlanId.FreePlus },