Skip to content

Commit 6fdb2ed

Browse files
committed
Fix #229: Pause polling when Workflows view is not visible
1 parent 964065c commit 6fdb2ed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/store/store.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@ export class RunStore extends EventEmitter<RunStoreEvent> {
2121
private runs = new Map<number, WorkflowRun>();
2222
private updaters = new Map<number, Updater>();
2323
private _isFocused = true;
24+
private _isViewVisible = true;
2425

2526
setFocused(focused: boolean) {
2627
this._isFocused = focused;
2728
logDebug(`[Store]: Focus state changed to ${focused}`);
2829
}
2930

31+
setViewVisible(visible: boolean) {
32+
this._isViewVisible = visible;
33+
logDebug(`[Store]: View visibility changed to ${visible}`);
34+
}
35+
3036
getRun(runId: number): WorkflowRun | undefined {
3137
return this.runs.get(runId);
3238
}
@@ -72,7 +78,7 @@ export class RunStore extends EventEmitter<RunStoreEvent> {
7278
}
7379

7480
private async fetchRun(updater: Updater) {
75-
if (!this._isFocused) {
81+
if (!this._isFocused || !this._isViewVisible) {
7682
return;
7783
}
7884

src/treeViews/treeViews.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@ import {WorkflowsTreeProvider} from "./workflows";
1111

1212
export async function initTreeViews(context: vscode.ExtensionContext, store: RunStore): Promise<void> {
1313
const workflowTreeProvider = new WorkflowsTreeProvider(store);
14-
context.subscriptions.push(vscode.window.registerTreeDataProvider("github-actions.workflows", workflowTreeProvider));
14+
const workflowTreeView = vscode.window.createTreeView("github-actions.workflows", {
15+
treeDataProvider: workflowTreeProvider
16+
});
17+
context.subscriptions.push(workflowTreeView);
18+
19+
store.setViewVisible(workflowTreeView.visible);
20+
workflowTreeView.onDidChangeVisibility(e => {
21+
store.setViewVisible(e.visible);
22+
});
1523

1624
const settingsTreeProvider = new SettingsTreeProvider();
1725
context.subscriptions.push(vscode.window.registerTreeDataProvider("github-actions.settings", settingsTreeProvider));

0 commit comments

Comments
 (0)