Browse Source

Fixes access on subscription change in graph

main
Keith Daulton 2 years ago
parent
commit
39baa3d80f
2 changed files with 21 additions and 12 deletions
  1. +7
    -3
      src/git/gitProviderService.ts
  2. +14
    -9
      src/plus/webviews/graph/graphWebview.ts

+ 7
- 3
src/git/gitProviderService.ts View File

@ -534,11 +534,15 @@ export class GitProviderService implements Disposable {
} }
if ( if (
access.visibility !== RepositoryVisibility.Private &&
access.subscription.current.plan.effective.id === SubscriptionPlanId.Free
(access.visibility !== RepositoryVisibility.Private &&
access.subscription.current.plan.effective.id === SubscriptionPlanId.Free) ||
(access.visibility === RepositoryVisibility.Private && access.subscription.current.previewTrial == null)
) { ) {
return { return {
allowed: true,
allowed: !(
access.visibility === RepositoryVisibility.Private &&
access.subscription.current.previewTrial == null
),
subscription: { current: access.subscription.current }, subscription: { current: access.subscription.current },
visibility: access.visibility, visibility: access.visibility,
}; };

+ 14
- 9
src/plus/webviews/graph/graphWebview.ts View File

@ -407,7 +407,7 @@ export class GraphWebview extends WebviewBase {
private async notifyDidChangeSubscription() { private async notifyDidChangeSubscription() {
if (!this.isReady || !this.visible) return false; if (!this.isReady || !this.visible) return false;
const access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
const access = await this.getGraphAccess();
return this.notify(DidChangeSubscriptionNotificationType, { return this.notify(DidChangeSubscriptionNotificationType, {
subscription: access.subscription.current, subscription: access.subscription.current,
allowed: access.allowed, allowed: access.allowed,
@ -465,14 +465,7 @@ export class GraphWebview extends WebviewBase {
const limit = this._graph?.paging?.limit ?? config.defaultItemLimit; const limit = this._graph?.paging?.limit ?? config.defaultItemLimit;
// Check for GitLens+ access // Check for GitLens+ access
let access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
this._etagSubscription = this.container.subscription.etag;
// If we don't have access to GitLens+, but the preview trial hasn't been started, auto-start it
if (!access.allowed && access.subscription.current.previewTrial == null) {
await this.container.subscription.startPreviewTrial(true);
access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
}
const access = await this.getGraphAccess();
const visibility = access.visibility ?? (await this.container.git.visibility(this.repository.path)); const visibility = access.visibility ?? (await this.container.git.visibility(this.repository.path));
@ -504,6 +497,18 @@ export class GraphWebview extends WebviewBase {
}; };
} }
private async getGraphAccess() {
let access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
this._etagSubscription = this.container.subscription.etag;
// If we don't have access to GitLens+, but the preview trial hasn't been started, auto-start it
if (!access.allowed && access.subscription.current.previewTrial == null) {
await this.container.subscription.startPreviewTrial(true);
access = await this.container.git.access(PlusFeatures.Graph, this.repository?.path);
}
return access;
}
private resetRepositoryState() { private resetRepositoryState() {
this.setGraph(undefined); this.setGraph(undefined);
this._selectedSha = undefined; this._selectedSha = undefined;

Loading…
Cancel
Save