Skip to content

Commit 184edcb

Browse files
Copilotalexr00
andcommitted
Reset auto-refresh timer when manual refresh occurs
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent d2fa0b9 commit 184edcb

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ declare module 'vscode' {
9595
*/
9696
description?: string | MarkdownString;
9797

98+
/**
99+
* An optional badge that provides additional context about the chat session.
100+
*/
101+
badge?: string | MarkdownString;
102+
98103
/**
99104
* An optional status indicating the current state of the session.
100105
*/

src/view/prsTreeDataProvider.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,20 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
197197
this._autoRefreshTimer = setInterval(() => {
198198
Logger.appendLine('Auto-refreshing pull requests queries', 'PullRequestsTreeDataProvider');
199199
this.prsTreeModel.forceClearCache();
200-
this.refreshAllQueryResults(true);
200+
this.tryReset(true);
201+
this.fireRefresh();
201202
}, intervalMs);
202203

203204
Logger.appendLine(`Auto-refresh enabled with interval of ${actualIntervalMinutes} minutes`, 'PullRequestsTreeDataProvider');
204205
}
205206

207+
private resetAutoRefreshTimer(): void {
208+
// Only reset if auto-refresh is currently enabled
209+
if (this._autoRefreshTimer) {
210+
this.setupAutoRefresh();
211+
}
212+
}
213+
206214
private filterNotificationsToKnown(notifications: PullRequestModel[]): PullRequestModel[] {
207215
return notifications.filter(notification => {
208216
if (!this.prsTreeModel.hasPullRequest(notification)) {
@@ -414,9 +422,7 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
414422
}
415423
}
416424

417-
private refreshAllQueryResults(reset?: boolean) {
418-
this.tryReset(!!reset);
419-
425+
private fireRefresh() {
420426
if (!this._children || this._children.length === 0) {
421427
this._onDidChangeTreeData.fire();
422428
return;
@@ -429,6 +435,15 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
429435
this.refreshQueryResultsForFolder();
430436
}
431437

438+
private refreshAllQueryResults(reset?: boolean) {
439+
this.tryReset(!!reset);
440+
441+
// Reset the auto-refresh timer whenever a refresh is triggered
442+
this.resetAutoRefreshTimer();
443+
444+
this.fireRefresh();
445+
}
446+
432447
private refreshQueryResultsForFolder(manager?: WorkspaceFolderNode, reset?: boolean) {
433448
if (!manager && this._children[0] instanceof WorkspaceFolderNode) {
434449
// Not permitted. There're multiple folder nodes, therefore must specify which one to refresh

0 commit comments

Comments
 (0)