From c1f728dcf029ef9eb03fc2ed744132ba9b160187 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Mon, 7 Feb 2022 14:01:24 +0100 Subject: [PATCH] After making a change to a PR that was made on a fork the "Files" tree is empty (#3296) --- src/view/prChangesTreeDataProvider.ts | 6 ++++++ src/view/treeNodes/commitsCategoryNode.ts | 5 +++-- src/view/treeNodes/fileChangeNode.ts | 9 --------- src/view/treeNodes/filesCategoryNode.ts | 9 +++++---- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/view/prChangesTreeDataProvider.ts b/src/view/prChangesTreeDataProvider.ts index 984b60d26a..1a7d548af6 100644 --- a/src/view/prChangesTreeDataProvider.ts +++ b/src/view/prChangesTreeDataProvider.ts @@ -73,6 +73,12 @@ export class PullRequestChangesTreeDataProvider extends vscode.Disposable implem reviewModel: ReviewModel, shouldReveal: boolean, ) { + if (this._pullRequestManagerMap.has(pullRequestManager)) { + const existingNode = this._pullRequestManagerMap.get(pullRequestManager); + if (existingNode && (existingNode.pullRequestModel === pullRequestModel)) { + return; + } + } const node: RepositoryChangesNode = new RepositoryChangesNode( this, pullRequestModel, diff --git a/src/view/treeNodes/commitsCategoryNode.ts b/src/view/treeNodes/commitsCategoryNode.ts index 8cee840063..a466c52a88 100644 --- a/src/view/treeNodes/commitsCategoryNode.ts +++ b/src/view/treeNodes/commitsCategoryNode.ts @@ -26,8 +26,9 @@ export class CommitsNode extends TreeNode implements vscode.TreeItem { this._folderRepoManager = reposManager; this.collapsibleState = vscode.TreeItemCollapsibleState.Collapsed; - this._pr.onDidChangeReviewThreads(() => this.refresh(this)); - this._pr.onDidChangeComments(() => this.refresh(this)); + this.childrenDisposables = []; + this.childrenDisposables.push(this._pr.onDidChangeReviewThreads(() => this.refresh(this))); + this.childrenDisposables.push(this._pr.onDidChangeComments(() => this.refresh(this))); } getTreeItem(): vscode.TreeItem { diff --git a/src/view/treeNodes/fileChangeNode.ts b/src/view/treeNodes/fileChangeNode.ts index 9494790da9..0d93447c55 100644 --- a/src/view/treeNodes/fileChangeNode.ts +++ b/src/view/treeNodes/fileChangeNode.ts @@ -233,15 +233,6 @@ export class FileChangeNode extends TreeNode implements vscode.TreeItem { }), ); - this.childrenDisposables.push(this.pullRequest.onDidChangeComments(() => { - this.updateShowOptions(); - this.refresh(this); - })); - - this.childrenDisposables.push(this.pullRequest.onDidChangeReviewThreads(() => { - this.updateShowOptions(); - this.refresh(this); - })); this.accessibilityInformation = { label: `View diffs and comments for file ${this.label}`, role: 'link' }; } diff --git a/src/view/treeNodes/filesCategoryNode.ts b/src/view/treeNodes/filesCategoryNode.ts index 33b6b258ef..56e80f8b58 100644 --- a/src/view/treeNodes/filesCategoryNode.ts +++ b/src/view/treeNodes/filesCategoryNode.ts @@ -17,13 +17,14 @@ export class FilesCategoryNode extends TreeNode implements vscode.TreeItem { constructor( public parent: TreeNodeParent, private _reviewModel: ReviewModel, - private _pullRequestModel: PullRequestModel + _pullRequestModel: PullRequestModel ) { super(); this.collapsibleState = vscode.TreeItemCollapsibleState.Expanded; - this._reviewModel.onDidChangeLocalFileChanges(() => this.refresh(this)); - this._pullRequestModel.onDidChangeReviewThreads(() => this.refresh(this)); - this._pullRequestModel.onDidChangeComments(() => this.refresh(this)); + this.childrenDisposables = []; + this.childrenDisposables.push(this._reviewModel.onDidChangeLocalFileChanges(() => this.refresh(this))); + this.childrenDisposables.push(_pullRequestModel.onDidChangeReviewThreads(() => this.refresh(this))); + this.childrenDisposables.push(_pullRequestModel.onDidChangeComments(() => this.refresh(this))); } getTreeItem(): vscode.TreeItem {