Skip to content

Commit 603fca1

Browse files
authored
Fix null errors on conversation holder (#32258) (#32266)
fix #32258 Errors in the issue was due to unhandled null check. so i fixed it. ### Detailed description for Issue & Fix To reproduce that issue, the comment must be deleted on Conversation tab. #### Before Delete <img width="1032" alt="image" src="https://github.com/user-attachments/assets/72df61ba-7db6-44c9-bebc-ca1178dd27f1"> #### After Delete (AS-IS) <img width="1010" alt="image" src="https://github.com/user-attachments/assets/36fa537e-4f8e-4535-8d02-e538c50f0dd8"> gitea already have remove logic for `timeline-item-group`, but because of null ref exception the later logic that removes `timeline-item-group` could be not be called correctly.
1 parent d50ed0a commit 603fca1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

web_src/js/features/repo-issue.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,17 @@ export function initRepoIssueCommentDelete() {
187187
const path = conversationHolder.getAttribute('data-path');
188188
const side = conversationHolder.getAttribute('data-side');
189189
const idx = conversationHolder.getAttribute('data-idx');
190-
const lineType = conversationHolder.closest('tr').getAttribute('data-line-type');
191-
192-
if (lineType === 'same') {
193-
document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible');
194-
} else {
195-
document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible');
190+
const lineType = conversationHolder.closest('tr')?.getAttribute('data-line-type');
191+
192+
// the conversation holder could appear either on the "Conversation" page, or the "Files Changed" page
193+
// on the Conversation page, there is no parent "tr", so no need to do anything for "add-code-comment"
194+
if (lineType) {
195+
if (lineType === 'same') {
196+
document.querySelector(`[data-path="${path}"] .add-code-comment[data-idx="${idx}"]`).classList.remove('tw-invisible');
197+
} else {
198+
document.querySelector(`[data-path="${path}"] .add-code-comment[data-side="${side}"][data-idx="${idx}"]`).classList.remove('tw-invisible');
199+
}
196200
}
197-
198201
conversationHolder.remove();
199202
}
200203

0 commit comments

Comments
 (0)