@@ -117,7 +117,7 @@ interface PageInformation {
117117
118118export class CategoryTreeNode extends TreeNode implements vscode . TreeItem {
119119 public collapsibleState : vscode . TreeItemCollapsibleState ;
120- public prs : PullRequestModel [ ] ;
120+ public prs : Map < number , PullRequestModel > ;
121121 public fetchNextPage : boolean = false ;
122122 public repositoryPageInformation : Map < string , PageInformation > = new Map < string , PageInformation > ( ) ;
123123 public contextValue : string ;
@@ -134,7 +134,7 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
134134 ) {
135135 super ( parent ) ;
136136
137- this . prs = [ ] ;
137+ this . prs = new Map ( ) ;
138138
139139 switch ( this . type ) {
140140 case PRType . All :
@@ -322,7 +322,8 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
322322 this . fetchNextPage = false ;
323323 if ( this . type === PRType . LocalPullRequest ) {
324324 try {
325- this . prs = ( await this . _prsTreeModel . getLocalPullRequests ( this . _folderRepoManager ) ) . items ;
325+ this . prs . clear ( ) ;
326+ ( await this . _prsTreeModel . getLocalPullRequests ( this . _folderRepoManager ) ) . items . forEach ( item => this . prs . set ( item . id , item ) ) ;
326327 } catch ( e ) {
327328 vscode . window . showErrorMessage ( vscode . l10n . t ( 'Fetching local pull requests failed: {0}' , formatError ( e ) ) ) ;
328329 needLogin = e instanceof AuthenticationError ;
@@ -339,10 +340,9 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
339340 break ;
340341 }
341342 if ( ! fetchNextPage ) {
342- this . prs = response . items ;
343- } else {
344- this . prs = this . prs . concat ( response . items ) ;
343+ this . prs . clear ( ) ;
345344 }
345+ response . items . forEach ( item => this . prs . set ( item . id , item ) ) ;
346346 hasMorePages = response . hasMorePages ;
347347 hasUnsearchedRepositories = response . hasUnsearchedRepositories ;
348348 } catch ( e ) {
@@ -360,8 +360,8 @@ export class CategoryTreeNode extends TreeNode implements vscode.TreeItem {
360360 }
361361 }
362362
363- if ( this . prs && this . prs . length ) {
364- const nodes : ( PRNode | PRCategoryActionNode ) [ ] = this . prs . map (
363+ if ( this . prs . size > 0 ) {
364+ const nodes : ( PRNode | PRCategoryActionNode ) [ ] = Array . from ( this . prs . values ( ) ) . map (
365365 prItem => new PRNode ( this , this . _folderRepoManager , prItem , this . type === PRType . LocalPullRequest , this . _notificationProvider ) ,
366366 ) ;
367367 if ( hasMorePages ) {
0 commit comments