From a1bbaf8d652db85fbbc22e51d17ae1d4b64c19db Mon Sep 17 00:00:00 2001 From: cloudchamb3r Date: Tue, 15 Oct 2024 17:22:53 +0900 Subject: [PATCH 1/3] fix null errors on conversation holder --- web_src/js/features/repo-issue.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index 4377292a64da9..53b7230e78ff5 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -187,12 +187,12 @@ export function initRepoIssueCommentDelete() { const path = conversationHolder.getAttribute('data-path'); const side = conversationHolder.getAttribute('data-side'); const idx = conversationHolder.getAttribute('data-idx'); - const lineType = conversationHolder.closest('tr').getAttribute('data-line-type'); + const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type'); if (lineType === 'same') { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible'); + document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`)?.classList.remove('tw-invisible'); } else { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible'); + document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`)?.classList.remove('tw-invisible'); } conversationHolder.remove(); From 32edc01585337848af022f2e256d5ec7c61edf41 Mon Sep 17 00:00:00 2001 From: cloudchamb3r Date: Wed, 16 Oct 2024 01:19:32 +0900 Subject: [PATCH 2/3] remove tw-invisible only if lineType is not null --- web_src/js/features/repo-issue.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index 53b7230e78ff5..a96e8f73210a3 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -188,13 +188,16 @@ export function initRepoIssueCommentDelete() { const side = conversationHolder.getAttribute('data-side'); const idx = conversationHolder.getAttribute('data-idx'); const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type'); - - if (lineType === 'same') { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`)?.classList.remove('tw-invisible'); - } else { - document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`)?.classList.remove('tw-invisible'); + + // the conversation holder could appear either on the "Conversation" page, or the "Files Changed" page + // on the Conversation page, there is no parent "tr", so no need to do anything for "add-code-comment" + if (lineType) { + if (lineType === 'same') { + document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible'); + } else { + document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible'); + } } - conversationHolder.remove(); } From d49698905f92652aab1a8890e6117e7c8624d9ec Mon Sep 17 00:00:00 2001 From: cloudchamb3r Date: Wed, 16 Oct 2024 01:22:57 +0900 Subject: [PATCH 3/3] fix lint error --- web_src/js/features/repo-issue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/repo-issue.ts b/web_src/js/features/repo-issue.ts index a96e8f73210a3..e450f561c0a85 100644 --- a/web_src/js/features/repo-issue.ts +++ b/web_src/js/features/repo-issue.ts @@ -188,7 +188,7 @@ export function initRepoIssueCommentDelete() { const side = conversationHolder.getAttribute('data-side'); const idx = conversationHolder.getAttribute('data-idx'); const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type'); - + // the conversation holder could appear either on the "Conversation" page, or the "Files Changed" page // on the Conversation page, there is no parent "tr", so no need to do anything for "add-code-comment" if (lineType) {