summaryrefslogtreecommitdiff
path: root/source/features/hide-useless-comments.tsx
diff options
context:
space:
mode:
authorGravatar Federico Brigante <github@bfred.it> 2020-01-07 00:19:09 +0700
committerGravatar GitHub <noreply@github.com> 2020-01-07 00:19:09 +0700
commit7f1f2c52d8deeb0fddb7a7322af7dd090ac19461 (patch)
tree6d5aba6a51777875918a609e4fdf2534870169be /source/features/hide-useless-comments.tsx
parentdac2a0302aad5462c3a6b896fc66b18391c73d12 (diff)
downloadrefined-github-7f1f2c52d8deeb0fddb7a7322af7dd090ac19461.tar.gz
refined-github-7f1f2c52d8deeb0fddb7a7322af7dd090ac19461.tar.zst
refined-github-7f1f2c52d8deeb0fddb7a7322af7dd090ac19461.zip
Keep features working after clicking the browser’s Back button (#2639)
Diffstat (limited to 'source/features/hide-useless-comments.tsx')
-rw-r--r--source/features/hide-useless-comments.tsx8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/features/hide-useless-comments.tsx b/source/features/hide-useless-comments.tsx
index be0b2ac1..edac8fa1 100644
--- a/source/features/hide-useless-comments.tsx
+++ b/source/features/hide-useless-comments.tsx
@@ -1,6 +1,7 @@
import './hide-useless-comments.css';
import React from 'dom-chef';
import select from 'select-dom';
+import delegate, {DelegateEvent} from 'delegate-it';
import features from '../libs/features';
function init(): void {
@@ -40,19 +41,20 @@ function init(): void {
select('.discussion-timeline-actions')!.prepend(
<p className="rgh-useless-comments-note">
{`${uselessCount} unhelpful comment${uselessCount > 1 ? 's were' : ' was'} automatically hidden. `}
- <button className="btn-link text-emphasized" onClick={unhide}>Show</button>
+ <button className="btn-link text-emphasized rgh-unhide-useless-comments">Show</button>
</p>
);
+ delegate('.rgh-unhide-useless-comments', 'click', unhide);
}
}
-function unhide(event: React.MouseEvent<HTMLButtonElement>): void {
+function unhide(event: DelegateEvent<MouseEvent, HTMLButtonElement>): void {
for (const comment of select.all('.rgh-hidden-comment')) {
comment.hidden = false;
}
select('.rgh-hidden-comment')!.scrollIntoView();
- event.currentTarget.parentElement!.remove();
+ event.delegateTarget.parentElement!.remove();
}
features.add({