diff --git a/web_src/js/index.js b/web_src/js/index.js index b8d6578c34..61059b6946 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1226,25 +1226,41 @@ function initPullRequestReview() { $(this).closest('tr').removeClass('focus-lines-new focus-lines-old'); }); $('.add-code-comment').on('click', function (e) { - // https://github.com/go-gitea/gitea/issues/4745 - if ($(e.target).hasClass('btn-add-single')) { - return; - } + if ($(e.target).hasClass('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745 e.preventDefault(); + const isSplit = $(this).closest('.code-diff').hasClass('code-diff-split'); const side = $(this).data('side'); const idx = $(this).data('idx'); const path = $(this).data('path'); const form = $('#pull_review_add_comment').html(); const tr = $(this).closest('tr'); + + const oldLineNum = tr.find('.lines-num-old').data('line-num'); + const newLineNum = tr.find('.lines-num-new').data('line-num'); + const addCommentKey = `${oldLineNum}|${newLineNum}`; + if (document.querySelector(`[data-add-comment-key="${addCommentKey}"]`)) return; // don't add same comment box twice + let ntr = tr.next(); if (!ntr.hasClass('add-comment')) { - ntr = $(`