diff options
Diffstat (limited to 'source/features/mark-unread.tsx')
-rw-r--r-- | source/features/mark-unread.tsx | 9 |
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()) { |