summaryrefslogtreecommitdiff
path: root/source/features/mark-unread.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/mark-unread.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/mark-unread.tsx')
-rw-r--r--source/features/mark-unread.tsx9
1 files changed, 5 insertions, 4 deletions
diff --git a/source/features/mark-unread.tsx b/source/features/mark-unread.tsx
index 373800da..dc8a2846 100644
--- a/source/features/mark-unread.tsx
+++ b/source/features/mark-unread.tsx
@@ -71,7 +71,7 @@ function stripHash(url: string): string {
function addMarkUnreadButton(): void {
if (!select.exists('.rgh-btn-mark-unread')) {
select('.thread-subscription-status')!.after(
- <button className="btn btn-sm btn-block mt-2 rgh-btn-mark-unread" onClick={markUnread}>
+ <button className="btn btn-sm btn-block mt-2 rgh-btn-mark-unread">
Mark as unread
</button>
);
@@ -96,7 +96,7 @@ async function markRead(urls: string|string[]): Promise<void> {
await setNotifications(updated);
}
-async function markUnread({currentTarget}: React.MouseEvent): Promise<void> {
+async function markUnread({delegateTarget}: DelegateEvent): Promise<void> {
const participants: Participant[] = select.all('.participant-avatar').slice(0, 3).map(element => ({
username: element.getAttribute('aria-label')!,
avatar: element.querySelector('img')!.src
@@ -135,8 +135,8 @@ async function markUnread({currentTarget}: React.MouseEvent): Promise<void> {
await setNotifications(unreadNotifications);
await updateUnreadIndicator();
- currentTarget.setAttribute('disabled', 'disabled');
- currentTarget.textContent = 'Marked as unread';
+ delegateTarget.setAttribute('disabled', 'disabled');
+ delegateTarget.textContent = 'Marked as unread';
}
function getNotification(notification: Notification): Element {
@@ -423,6 +423,7 @@ async function init(): Promise<void> {
if (pageDetect.isPRConversation() || pageDetect.isIssue()) {
addMarkUnreadButton();
onUpdatableContentUpdate(select('#partial-discussion-sidebar')!, addMarkUnreadButton);
+ delegate('.rgh-btn-mark-unread', 'click', markUnread);
}
} else if (pageDetect.isDiscussionList()) {
for (const discussion of await getNotifications()) {