in src/desktop/tree_view/items/mr_item_model.ts [133:178]
async getChildren(): Promise<vscode.TreeItem[]> {
try {
const { mrVersion } = await mrCache.reloadMr(this.mr, this.projectInRepository);
// don't initialize comments twice
if (!this.#allUrisWithComments) {
const discussions = await this.#getMrDiscussions();
await this.#addAllCommentsToVsCode(mrVersion, discussions);
this.#allUrisWithComments = discussions.map(d =>
uriForDiscussion(
this.projectInRepository.pointer.repository.rootFsPath,
this.mr,
d,
mrVersion,
).toString(),
);
}
const hasCommentsFn: HasCommentsFn = uri =>
(this.#allUrisWithComments as string[]).includes(uri.toString());
const createChangedFiles = (shownInList: boolean): FolderTreeItem[] =>
mrVersion.diffs.map(diff => ({
path: diff.new_path || diff.old_path,
item: new ChangedFileItem(
this.mr,
mrVersion as RestMrVersion,
diff,
this.projectInRepository.pointer.repository.rootFsPath,
hasCommentsFn,
shownInList,
),
}));
const changedFiles =
getSidebarViewState() === SidebarViewState.TreeView
? new ChangedFolderItem('', createChangedFiles(false)).getChildren()
: createChangedFiles(true).map(file => file.item);
return [this.#overviewItem, ...changedFiles];
} catch (e) {
handleError(new UserFriendlyError('Failed to fetch details of the MR', e));
return [this.#overviewItem];
}
}