Просмотр исходного кода

Fixes access on subscription change in graph

main
Keith Daulton 2 лет назад
Родитель
Сommit
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;

Загрузка…
Отмена
Сохранить