summaryrefslogtreecommitdiff
path: root/source/features/preview-hidden-comments.tsx
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-06-26 04:30:43 -0400
committerGravatar GitHub <noreply@github.com> 2020-06-26 10:30:43 +0200
commitc6c727ca571c91d1ff426e218ccadb075cdb2af6 (patch)
treee1855bb6c6d37f0b28b97be73192316fec2067e5 /source/features/preview-hidden-comments.tsx
parent15da229b3a29483f076782361ac429854f18e18b (diff)
downloadrefined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.tar.gz
refined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.tar.zst
refined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.zip
Lint and avoid errors (#3256)
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>
);
}
};