Skip to content

Commit fa25bae

Browse files
committed
Avoids extra initial home re-render/fetch
1 parent 2ff7dde commit fa25bae

File tree

2 files changed

+12
-27
lines changed

2 files changed

+12
-27
lines changed

src/webviews/apps/plus/home/components/overviewState.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
DidChangeOverviewFilter,
77
DidChangeRepositories,
88
DidChangeRepositoryWip,
9-
DidCompleteDiscoveringRepositories,
109
GetOverview,
1110
GetOverviewFilterState,
1211
} from '../../../../home/protocol';
@@ -34,11 +33,6 @@ export class OverviewState extends AsyncComputedState<Overview> {
3433

3534
this._disposable = this._ipc.onReceiveMessage(msg => {
3635
switch (true) {
37-
case DidCompleteDiscoveringRepositories.is(msg):
38-
if (msg.params.repositories.openCount > 0) {
39-
this.run(true);
40-
}
41-
break;
4236
case DidChangeRepositories.is(msg):
4337
this.run(true);
4438
break;

src/webviews/home/homeWebview.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -194,26 +194,13 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
194194
}
195195

196196
this._discovering = this.container.git.isDiscoveringRepositories;
197+
void this._discovering.finally(() => (this._discovering = undefined));
197198
this._etag = await this._discovering;
198-
this._discovering = undefined;
199199
this.notifyDidCompleteDiscoveringRepositories();
200200
}
201201

202202
private onChangeConnectionState() {
203-
void this.notifyDidChangeOnboardingIntegration();
204-
}
205-
206-
private async shouldNotifyRepositoryChange(): Promise<boolean> {
207-
if (this._etag === this.container.git.etag) {
208-
return false;
209-
}
210-
211-
if (this._discovering != null) {
212-
this._etag = await this._discovering;
213-
if (this._etag === this.container.git.etag) return false;
214-
}
215-
216-
return true;
203+
void this.notifyDidChangeIntegrations();
217204
}
218205

219206
private async onChooseRepository() {
@@ -237,10 +224,9 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
237224
this.selectRepository(pick.path);
238225
}
239226

240-
private async onRepositoriesChanged() {
241-
if (!(await this.shouldNotifyRepositoryChange())) {
242-
return;
243-
}
227+
private onRepositoriesChanged() {
228+
if (this._discovering != null || this._etag === this.container.git.etag) return;
229+
244230
this.notifyDidChangeRepositories();
245231
}
246232

@@ -394,7 +380,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
394380
}
395381

396382
this.resumeRepositorySubscription();
397-
this.notifyDidChangeRepositories(true);
383+
384+
if (this._discovering == null && this._etag !== this.container.git.etag) {
385+
this.notifyDidChangeRepositories(true);
386+
}
398387
}
399388

400389
private openInGraph(params: OpenInGraphParams) {
@@ -903,6 +892,8 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
903892
}
904893
private _notifyDidChangeRepositoriesDebounced: Deferrable<() => void> | undefined = undefined;
905894
private notifyDidChangeRepositories(immediate = false) {
895+
if (this._discovering != null) return;
896+
906897
if (immediate) {
907898
this.notifyDidChangeRepositoriesCore();
908899
return;
@@ -934,7 +925,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
934925
void this.host.notify(DidChangeLaunchpad, undefined);
935926
}
936927

937-
private async notifyDidChangeOnboardingIntegration() {
928+
private async notifyDidChangeIntegrations() {
938929
// force rechecking
939930
const integrations = await this.getIntegrationStates(true);
940931
const anyConnected = integrations.some(i => i.connected);

0 commit comments

Comments
 (0)