|
4 | 4 | *--------------------------------------------------------------------------------------------*/ |
5 | 5 |
|
6 | 6 | import * as vscode from 'vscode'; |
| 7 | +import { debounce } from '../common/async'; |
7 | 8 | import { COPILOT_ACCOUNTS } from '../common/comment'; |
8 | 9 | import { COPILOT_LOGINS, copilotEventToStatus, CopilotPRStatus } from '../common/copilot'; |
9 | 10 | import { Disposable } from '../common/lifecycle'; |
@@ -61,11 +62,11 @@ export class CopilotStateModel extends Disposable { |
61 | 62 | changedModels.push(pullRequestModel); |
62 | 63 | changedKeys.push(key); |
63 | 64 | } |
64 | | - if (this._isInitialized) { |
65 | | - changedKeys.forEach(key => this._showNotification.add(key)); |
66 | | - this._onDidChangeNotifications.fire(changedModels); |
67 | | - } |
68 | 65 | if (changedModels.length > 0) { |
| 66 | + if (this._isInitialized) { |
| 67 | + changedKeys.forEach(key => this._showNotification.add(key)); |
| 68 | + this._onDidChangeNotifications.fire(changedModels); |
| 69 | + } |
69 | 70 | this._onDidChangeStates.fire(); |
70 | 71 | } |
71 | 72 | } |
@@ -139,7 +140,12 @@ export class CopilotPRWatcher extends Disposable { |
139 | 140 | private _initialize() { |
140 | 141 | this._getStateChanges(); |
141 | 142 | this._pollForChanges(); |
142 | | - this._register(this._reposManager.onDidChangeAnyPullRequests(() => this._getStateChanges())); |
| 143 | + const updateState = debounce(() => this._getStateChanges(), 50); |
| 144 | + this._register(this._reposManager.onDidChangeAnyPullRequests(e => { |
| 145 | + if (e.some(pr => COPILOT_ACCOUNTS[pr.model.author.login])) { |
| 146 | + updateState(); |
| 147 | + } |
| 148 | + })); |
143 | 149 | this._register(PullRequestOverviewPanel.onVisible(e => this._model.clearNotification(e.remote.owner, e.remote.repositoryName, e.number))); |
144 | 150 |
|
145 | 151 | this._register(vscode.workspace.onDidChangeConfiguration(e => { |
|
0 commit comments