From a3efd048a7770aff898096df55eda76e80a4972e Mon Sep 17 00:00:00 2001 From: Jimmy Praet Date: Mon, 22 Nov 2021 13:20:16 +0100 Subject: Improvements to content history (#17746) * Improvements to content history * initialize content history when making an edit to an old item created before the introduction of content history * show edit history for code comments on pull request files tab * Fix a flaw in keepLimitedContentHistory Fix a flaw in keepLimitedContentHistory, the first and the last should never be deleted * Remove obsolete eager initialization of content history --- web_src/js/features/repo-issue-content.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'web_src/js/features') diff --git a/web_src/js/features/repo-issue-content.js b/web_src/js/features/repo-issue-content.js index a2fc6c3cbe..602523f89d 100644 --- a/web_src/js/features/repo-issue-content.js +++ b/web_src/js/features/repo-issue-content.js @@ -106,8 +106,11 @@ function showContentHistoryMenu(issueBaseUrl, $item, commentId) { export function initRepoIssueContentHistory() { const issueIndex = $('#issueIndex').val(); - const $itemIssue = $('.timeline-item.comment.first'); - if (!issueIndex || !$itemIssue.length) return; + if (!issueIndex) return; + + const $itemIssue = $('.repository.issue .timeline-item.comment.first'); // issue(PR) main content + const $comments = $('.repository.issue .comment-list .comment'); // includes: issue(PR) comments, code rerview comments + if (!$itemIssue.length && !$comments.length) return; const repoLink = $('#repolink').val(); const issueBaseUrl = `${appSubUrl}/${repoLink}/issues/${issueIndex}`; @@ -123,7 +126,7 @@ export function initRepoIssueContentHistory() { i18nTextDeleteFromHistoryConfirm = resp.i18n.textDeleteFromHistoryConfirm; i18nTextOptions = resp.i18n.textOptions; - if (resp.editedHistoryCountMap[0]) { + if (resp.editedHistoryCountMap[0] && $itemIssue.length) { showContentHistoryMenu(issueBaseUrl, $itemIssue, '0'); } for (const [commentId, _editedCount] of Object.entries(resp.editedHistoryCountMap)) { -- cgit v1.2.3