Kaynağa Gözat

Avoids refresh on initial load while discovering

main
Eric Amodio 1 yıl önce
ebeveyn
işleme
07c9c63d07
2 değiştirilmiş dosya ile 38 ekleme ve 14 silme
  1. +17
    -13
      src/git/gitProviderService.ts
  2. +21
    -1
      src/plus/webviews/focus/focusWebview.ts

+ 17
- 13
src/git/gitProviderService.ts Dosyayı Görüntüle

@ -142,9 +142,11 @@ export class GitProviderService implements Disposable {
get onDidChangeRepositories(): Event<RepositoriesChangeEvent> {
return this._onDidChangeRepositories.event;
}
private fireRepositoriesChanged(added?: Repository[], removed?: Repository[]) {
const openSchemes = this.openRepositories.map(r => r.uri.scheme);
if (this.container.telemetry.enabled) {
const openSchemes = this.openRepositories.map(r => r.uri.scheme);
this.container.telemetry.setGlobalAttributes({
'repositories.count': openSchemes.length,
'repositories.schemes': joinUnique(openSchemes, ','),
@ -163,7 +165,7 @@ export class GitProviderService implements Disposable {
this._onDidChangeRepositories.fire({ added: added ?? [], removed: removed ?? [], etag: this._etag });
if (added?.length && this.container.telemetry.enabled) {
queueMicrotask(async () => {
setTimeout(async () => {
for (const repo of added) {
const remoteProviders = new Set<string>();
@ -181,7 +183,7 @@ export class GitProviderService implements Disposable {
'repository.remoteProviders': join(remoteProviders, ','),
});
}
});
}, 0);
}
}
@ -541,10 +543,12 @@ export class GitProviderService implements Disposable {
>('git.autoRepositoryDetection');
if (this.container.telemetry.enabled) {
queueMicrotask(() =>
this.container.telemetry.sendEvent('providers/registrationComplete', {
'config.git.autoRepositoryDetection': autoRepositoryDetection,
}),
setTimeout(
() =>
this.container.telemetry.sendEvent('providers/registrationComplete', {
'config.git.autoRepositoryDetection': autoRepositoryDetection,
}),
0,
);
}
@ -576,8 +580,8 @@ export class GitProviderService implements Disposable {
private _discoveredWorkspaceFolders = new Map<WorkspaceFolder, Promise<Repository[]>>();
private _isDiscoveringRepositories: Promise<void> | undefined;
get isDiscoveringRepositories(): Promise<void> | undefined {
private _isDiscoveringRepositories: Promise<number> | undefined;
get isDiscoveringRepositories(): Promise<number> | undefined {
return this._isDiscoveringRepositories;
}
@ -588,7 +592,7 @@ export class GitProviderService implements Disposable {
this._isDiscoveringRepositories = undefined;
}
const deferred = defer<void>();
const deferred = defer<number>();
this._isDiscoveringRepositories = deferred.promise;
try {
@ -630,7 +634,7 @@ export class GitProviderService implements Disposable {
queueMicrotask(() => this.fireRepositoriesChanged(added));
}
} finally {
deferred.fulfill();
queueMicrotask(() => deferred.fulfill(this._etag));
}
}
@ -910,7 +914,7 @@ export class GitProviderService implements Disposable {
if (visibility == null) {
visibility = await this.visibilityCore(repoPath);
if (this.container.telemetry.enabled) {
queueMicrotask(() => {
setTimeout(() => {
const repo = this.getRepository(repoPath);
this.container.telemetry.sendEvent('repository/visibility', {
'repository.visibility': visibility,
@ -920,7 +924,7 @@ export class GitProviderService implements Disposable {
'repository.folder.scheme': repo?.folder?.uri.scheme,
'repository.provider.id': repo?.provider.id,
});
});
}, 0);
}
}
return visibility;

+ 21
- 1
src/plus/webviews/focus/focusWebview.ts Dosyayı Görüntüle

@ -84,7 +84,9 @@ interface SearchedIssueWithRank extends SearchedIssue {
export class FocusWebviewProvider implements WebviewProvider<State> {
private _pullRequests: SearchedPullRequestWithRemote[] = [];
private _issues: SearchedIssueWithRank[] = [];
private _discovering: Promise<number | undefined> | undefined;
private readonly _disposable: Disposable;
private _etag?: number;
private _etagSubscription?: number;
private _repositoryEventsDisposable?: Disposable;
private _repos?: RepoWithRichRemote[];
@ -96,7 +98,16 @@ export class FocusWebviewProvider implements WebviewProvider {
) {
this._disposable = Disposable.from(
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
this.container.git.onDidChangeRepositories(() => void this.host.refresh(true)),
this.container.git.onDidChangeRepositories(async () => {
if (this._etag !== this.container.git.etag) {
if (this._discovering != null) {
this._etag = await this._discovering;
if (this._etag === this.container.git.etag) return;
}
void this.host.refresh(true);
}
}),
);
}
@ -424,6 +435,15 @@ export class FocusWebviewProvider implements WebviewProvider {
private async getState(force?: boolean, deferState?: boolean): Promise<State> {
const webviewId = this.host.id;
this._etag = this.container.git.etag;
if (this.container.git.isDiscoveringRepositories) {
this._discovering = this.container.git.isDiscoveringRepositories.then(r => {
this._discovering = undefined;
return r;
});
this._etag = await this._discovering;
}
const access = await this.getAccess(force);
if (access.allowed !== true) {
return {

Yükleniyor…
İptal
Kaydet