sindresorhus / notifier-for-github

Browser extension - Get notified about new GitHub notifications
MIT License
1.82k stars 133 forks source link

Only register the notification click handler once #267

Closed mrmr1993 closed 2 years ago

mrmr1993 commented 2 years ago

This PR replaces the handler for browser.notification.onClicked.addListener with a named function, which avoids re-registering the handler on every call to addHandlers.

Note that addEventListener called repeatedly with the same arguments will not register the same event listener multiple times (see the EventTarget.addEventListener spec for more info). This means that using the same named function for each call to addHandlers will only call that function once, where the previous code added a new anonymous function for each call.

This fixes #234, where clicking a notification would result in multiple tabs being opened, depending on the number of times that addHandlers was called.

sindresorhus commented 2 years ago

Linting is failing