summaryrefslogtreecommitdiff
path: root/source/features/preview-hidden-comments.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/features/preview-hidden-comments.tsx')
-rw-r--r--source/features/preview-hidden-comments.tsx13
1 files changed, 6 insertions, 7 deletions
diff --git a/source/features/preview-hidden-comments.tsx b/source/features/preview-hidden-comments.tsx
index f07b6bda..14a794b3 100644
--- a/source/features/preview-hidden-comments.tsx
+++ b/source/features/preview-hidden-comments.tsx
@@ -4,11 +4,10 @@ import select from 'select-dom';
import * as pageDetect from 'github-url-detection';
import features from '.';
+import {upperCaseFirst} from '../github-helpers';
const allowedReasons = new Set(['resolved', 'outdated', 'off-topic']);
-const capitalize = (text: string): string => text.charAt(0).toUpperCase() + text.slice(1);
-
const init = (): void => {
for (const details of select.all('.minimized-comment:not(.d-none) > details:not(.rgh-preview-hidden-comments)')) {
details.classList.add('rgh-preview-hidden-comments');
@@ -18,10 +17,10 @@ const init = (): void => {
continue;
}
- const header = select(`
- summary .timeline-comment-header-text,
- summary .discussion-item-copy
- `, details)!;
+ const header = select([
+ 'summary .timeline-comment-header-text', // Issue and commit comments
+ '.discussion-item-icon + div' // Review Comments
+ ], details)!;
const reason = /was marked as ([^.]+)/.exec(header.textContent!)?.[1] ?? '';
if (!allowedReasons.has(reason)) {
@@ -30,7 +29,7 @@ const init = (): void => {
header.append(
<span className="Details-content--open">{header.firstChild}</span>,
- <span className="Details-content--closed">{`${capitalize(reason)} — ${commentText}`}</span>
+ <span className="Details-content--closed">{`${upperCaseFirst(reason)} — ${commentText}`}</span>
);
}
};