Skip to content

Commit 359dbd2

Browse files
Copilotalexr00
andcommitted
Add notification change listeners to PRNode
Listen for notification changes from both NotificationsManager and PrsTreeModel. When a notification affecting this PR changes, refresh the node to update its context value, which controls whether the dismiss notification option appears. Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 072bbf4 commit 359dbd2

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

src/view/treeNodes/pullRequestNode.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
5757
super(parent);
5858
this.registerSinceReviewChange();
5959
this.registerConfigurationChange();
60+
this.registerNotificationChanges();
6061
this._register(this._folderReposManager.onDidChangeActivePullRequest(e => {
6162
if (e.new?.number === this.pullRequestModel.number || e.old?.number === this.pullRequestModel.number) {
6263
this.refresh(this);
@@ -144,6 +145,37 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
144145
}));
145146
}
146147

148+
protected registerNotificationChanges() {
149+
// Listen for regular notification changes
150+
this._register(this._notificationProvider.onDidChangeNotifications(notifications => {
151+
// Check if any of the changed notifications are for this PR
152+
const affectsThisPR = notifications.some(notification => {
153+
if (notification.model instanceof PullRequestModel) {
154+
return notification.model.number === this.pullRequestModel.number &&
155+
notification.model.remote.owner === this.pullRequestModel.remote.owner &&
156+
notification.model.remote.repositoryName === this.pullRequestModel.remote.repositoryName;
157+
}
158+
return false;
159+
});
160+
if (affectsThisPR) {
161+
this.refresh(this);
162+
}
163+
}));
164+
165+
// Listen for Copilot notification changes
166+
this._register(this._prsTreeModel.onDidChangeCopilotNotifications(pullRequests => {
167+
// Check if any of the changed notifications are for this PR
168+
const affectsThisPR = pullRequests.some(pr =>
169+
pr.number === this.pullRequestModel.number &&
170+
pr.remote.owner === this.pullRequestModel.remote.owner &&
171+
pr.remote.repositoryName === this.pullRequestModel.remote.repositoryName
172+
);
173+
if (affectsThisPR) {
174+
this.refresh(this);
175+
}
176+
}));
177+
}
178+
147179
public async reopenNewPrDiffs(pullRequest: PullRequestModel) {
148180
let hasOpenDiff: boolean = false;
149181
vscode.window.tabGroups.all.map(tabGroup => {

0 commit comments

Comments
 (0)