Skip to content

Commit d836efd

Browse files
committed
Changes launchpad view refresh cmd to refresh data
Refreshes launchpad view when data is refreshed Gates launchpad provider to avoid overlapping calls Avoids extra refresh on indicator startup if already refreshed
1 parent f88f1d7 commit d836efd

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/plus/focus/focusIndicator.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class FocusIndicator implements Disposable {
2727
private _categorizedItems: FocusItem[] | undefined;
2828
/** Tracks if this is the first state after startup */
2929
private _firstStateAfterStartup: boolean = true;
30+
private _hasRefreshed: boolean = false;
3031
private _lastDataUpdate: Date | undefined;
3132
private _lastRefreshPaused: Date | undefined;
3233
private _refreshTimer: ReturnType<typeof setInterval> | undefined;
@@ -119,6 +120,7 @@ export class FocusIndicator implements Disposable {
119120
}
120121

121122
private onFocusRefreshed(e: FocusRefreshEvent) {
123+
this._hasRefreshed = true;
122124
if (!this.pollingEnabled) {
123125
this.updateStatusBarState('idle');
124126

@@ -211,7 +213,12 @@ export class FocusIndicator implements Disposable {
211213
// If we are loading at startup, wait to give vscode time to settle before querying
212214
if (starting) {
213215
// Using a wait here, instead using the `startDelay` to avoid case where the timer could be cancelled if the user focused a different windows before the timer fires (because we will cancel the timer)
214-
void wait(5000).then(() => this.provider.getCategorizedItems({ force: true }));
216+
void wait(5000).then(() => {
217+
// If something else has already caused a refresh, don't do another one
218+
if (this._hasRefreshed) return;
219+
220+
void this.provider.getCategorizedItems({ force: true });
221+
});
215222
} else {
216223
void this.provider.getCategorizedItems({ force: true });
217224
}

src/plus/focus/focusProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { CodeSuggestionCounts, Draft } from '../../gk/models/drafts';
2121
import { executeCommand, registerCommand } from '../../system/command';
2222
import { configuration } from '../../system/configuration';
2323
import { setContext } from '../../system/context';
24+
import { gate } from '../../system/decorators/gate';
2425
import { debug, log } from '../../system/decorators/log';
2526
import { filterMap, groupByMap, map, some } from '../../system/iterable';
2627
import { Logger } from '../../system/logger';
@@ -630,13 +631,16 @@ export class FocusProvider implements Disposable {
630631
return repoRemotes;
631632
}
632633

634+
@gate<FocusProvider['getCategorizedItems']>(o => `${o?.force ?? false}`)
633635
@log<FocusProvider['getCategorizedItems']>({ args: { 0: o => `force=${o?.force}`, 1: false } })
634636
async getCategorizedItems(
635637
options?: { force?: boolean },
636638
cancellation?: CancellationToken,
637639
): Promise<FocusCategorizedResult> {
638640
const scope = getLogScope();
639641

642+
const fireRefresh = options?.force || this._prs == null;
643+
640644
const ignoredRepositories = new Set(
641645
(configuration.get('launchpad.ignoredRepositories') ?? []).map(r => r.toLowerCase()),
642646
);
@@ -812,10 +816,8 @@ export class FocusProvider implements Disposable {
812816
return result;
813817
} finally {
814818
this.updateGroupedIds(result?.items ?? []);
815-
if (result != null) {
819+
if (result != null && fireRefresh) {
816820
this._onDidRefresh.fire(result);
817-
} else {
818-
debugger;
819821
}
820822
}
821823
}

src/views/launchpadView.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun
184184
protected override onVisibilityChanged(e: TreeViewVisibilityChangeEvent): void {
185185
if (this._disposable == null) {
186186
this._disposable = Disposable.from(
187-
this.container.subscription.onDidChange(() => this.refresh(true), this),
188-
this.container.integrations.onDidChangeConnectionState(() => this.refresh(true), this),
187+
this.container.integrations.onDidChangeConnectionState(() => this.refresh(), this),
188+
this.container.focus.onDidRefresh(() => this.refresh(), this),
189189
);
190190
}
191191

@@ -237,7 +237,14 @@ export class LaunchpadView extends ViewBase<'launchpad', LaunchpadViewNode, Laun
237237
() => executeCommand(Commands.ViewsCopy, this.activeSelection, this.selection),
238238
this,
239239
),
240-
registerViewCommand(this.getQualifiedCommand('refresh'), () => this.refresh(true), this),
240+
registerViewCommand(
241+
this.getQualifiedCommand('refresh'),
242+
() =>
243+
window.withProgress({ location: { viewId: this.id } }, () =>
244+
this.container.focus.getCategorizedItems({ force: true }),
245+
),
246+
this,
247+
),
241248
registerViewCommand(
242249
this.getQualifiedCommand('setFilesLayoutToAuto'),
243250
() => this.setFilesLayout('auto'),

0 commit comments

Comments
 (0)