Skip to content

Commit b9ea7df

Browse files
authored
Fix extra search API calls when polling for Padawan PR changes (#7543)
Part of #7542
1 parent b39fd28 commit b9ea7df

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/github/copilotPrWatcher.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7+
import { debounce } from '../common/async';
78
import { COPILOT_ACCOUNTS } from '../common/comment';
89
import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus } from '../common/copilot';
910
import { Disposable } from '../common/lifecycle';
@@ -61,11 +62,11 @@ export class CopilotStateModel extends Disposable {
6162
changedModels.push(pullRequestModel);
6263
changedKeys.push(key);
6364
}
64-
if (this._isInitialized) {
65-
changedKeys.forEach(key => this._showNotification.add(key));
66-
this._onDidChangeNotifications.fire(changedModels);
67-
}
6865
if (changedModels.length > 0) {
66+
if (this._isInitialized) {
67+
changedKeys.forEach(key => this._showNotification.add(key));
68+
this._onDidChangeNotifications.fire(changedModels);
69+
}
6970
this._onDidChangeStates.fire();
7071
}
7172
}
@@ -139,7 +140,11 @@ export class CopilotPRWatcher extends Disposable {
139140
private _initialize() {
140141
this._getStateChanges();
141142
this._pollForChanges();
142-
this._register(this._reposManager.onDidChangeAnyPullRequests(() => this._getStateChanges()));
143+
this._register(this._reposManager.onDidChangeAnyPullRequests(e => {
144+
if (e.some(pr => COPILOT_ACCOUNTS[pr.model.author.login])) {
145+
debounce(this._getStateChanges, 50);
146+
}
147+
}));
143148
this._register(PullRequestOverviewPanel.onVisible(e => this._model.clearNotification(e.remote.owner, e.remote.repositoryName, e.number)));
144149

145150
this._register(vscode.workspace.onDidChangeConfiguration(e => {

0 commit comments

Comments
 (0)