Loading src/tree_view/items/mr_item_model.test.ts +4 −4 Original line number Diff line number Diff line Loading @@ -121,15 +121,15 @@ describe('MrItemModel', () => { expect(commentController.commentingRangeProvider).toBeInstanceOf(CommentingRangeProvider); }); it('when we create comment controller for the same MR, we dispose the previously created controller', async () => { it('keeps the same commentController regardless how many times we call getChildren', async () => { await item.getChildren(); expect(commentController.dispose).not.toHaveBeenCalled(); expect(createCommentControllerMock).toHaveBeenCalledTimes(1); // simulates another MR item opening the same MR await item.getChildren(); expect(commentController.dispose).toHaveBeenCalled(); expect(createCommentControllerMock).toHaveBeenCalledTimes(1); expect(commentController.dispose).not.toHaveBeenCalled(); }); }); }); src/tree_view/items/mr_item_model.ts +5 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ const uriForDiscussion = ( }; export class MrItemModel extends ItemModel { private cachedChildren?: vscode.TreeItem[]; constructor(readonly mr: RestMr, readonly repository: WrappedRepository) { super(); } Loading Loading @@ -96,6 +98,7 @@ export class MrItemModel extends ItemModel { } async getChildren(): Promise<vscode.TreeItem[]> { if (this.cachedChildren) return this.cachedChildren; // don't initialize comments twice const { mrVersion } = await this.repository.reloadMr(this.mr); const discussions = await this.getMrDiscussions(); Loading @@ -110,7 +113,8 @@ export class MrItemModel extends ItemModel { allUrisWithComments.includes(uri.toString()), ), ); return [this.overviewItem, ...changedFiles]; this.cachedChildren = [this.overviewItem, ...changedFiles]; return this.cachedChildren; } private async addAllCommentsToVsCode( Loading Loading
src/tree_view/items/mr_item_model.test.ts +4 −4 Original line number Diff line number Diff line Loading @@ -121,15 +121,15 @@ describe('MrItemModel', () => { expect(commentController.commentingRangeProvider).toBeInstanceOf(CommentingRangeProvider); }); it('when we create comment controller for the same MR, we dispose the previously created controller', async () => { it('keeps the same commentController regardless how many times we call getChildren', async () => { await item.getChildren(); expect(commentController.dispose).not.toHaveBeenCalled(); expect(createCommentControllerMock).toHaveBeenCalledTimes(1); // simulates another MR item opening the same MR await item.getChildren(); expect(commentController.dispose).toHaveBeenCalled(); expect(createCommentControllerMock).toHaveBeenCalledTimes(1); expect(commentController.dispose).not.toHaveBeenCalled(); }); }); });
src/tree_view/items/mr_item_model.ts +5 −1 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ const uriForDiscussion = ( }; export class MrItemModel extends ItemModel { private cachedChildren?: vscode.TreeItem[]; constructor(readonly mr: RestMr, readonly repository: WrappedRepository) { super(); } Loading Loading @@ -96,6 +98,7 @@ export class MrItemModel extends ItemModel { } async getChildren(): Promise<vscode.TreeItem[]> { if (this.cachedChildren) return this.cachedChildren; // don't initialize comments twice const { mrVersion } = await this.repository.reloadMr(this.mr); const discussions = await this.getMrDiscussions(); Loading @@ -110,7 +113,8 @@ export class MrItemModel extends ItemModel { allUrisWithComments.includes(uri.toString()), ), ); return [this.overviewItem, ...changedFiles]; this.cachedChildren = [this.overviewItem, ...changedFiles]; return this.cachedChildren; } private async addAllCommentsToVsCode( Loading