瀏覽代碼

Fixes access on subscription change in graph

main
Keith Daulton 2 年之前
父節點
當前提交
39baa3d80f
共有 2 個文件被更改,包括 21 次插入12 次删除
  1. +7
    -3
      src/git/gitProviderService.ts
  2. +14
    -9
      src/plus/webviews/graph/graphWebview.ts

+ 7
- 3
src/git/gitProviderService.ts 查看文件

@ -534,11 +534,15 @@ export class GitProviderService implements Disposable {
}
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 {
allowed: true,
allowed: !(
access.visibility === RepositoryVisibility.Private &&
access.subscription.current.previewTrial == null
),
subscription: { current: access.subscription.current },
visibility: access.visibility,
};

+ 14
- 9
src/plus/webviews/graph/graphWebview.ts 查看文件

@ -407,7 +407,7 @@ export class GraphWebview extends WebviewBase {
private async notifyDidChangeSubscription() {
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, {
subscription: access.subscription.current,
allowed: access.allowed,
@ -465,14 +465,7 @@ export class GraphWebview extends WebviewBase {
const limit = this._graph?.paging?.limit ?? config.defaultItemLimit;
// 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));
@ -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() {
this.setGraph(undefined);
this._selectedSha = undefined;

Loading…
取消
儲存