Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sanity checks for permissions #279

Conversation

mabrikan
Copy link
Contributor

@mabrikan mabrikan commented Mar 9, 2023

Fixes #278.

browser.notifications.create is undefined when notification permission is not granted.

This makes calls to function showNotifications fail stopping the program flow and preventing saving lastModified field.

Also perhaps we need to unset permission-related options whenever a permission is removed.
onRemove[1] listener is a good approach.

[1]
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onRemoved

@mabrikan mabrikan force-pushed the fix/check-for-notifications-permission-before-showing-them branch from 3fa9ac4 to f4d7b91 Compare March 9, 2023 23:36
@notlmn
Copy link
Collaborator

notlmn commented Mar 10, 2023

Also perhaps we need to unset permission-related options whenever a permission is removed. onRemove[1] listener is a good approach.

[1] developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/onRemoved

I'm not sure if we can keep the options storage and permissions from the browser side in sync. The best approach as you have documented here is to always check for permissions before performing any action.

@notlmn notlmn merged commit 0f20955 into sindresorhus:main Mar 10, 2023
@notlmn
Copy link
Collaborator

notlmn commented Mar 10, 2023

Thanks for the CL 🙌

@mabrikan mabrikan deleted the fix/check-for-notifications-permission-before-showing-them branch March 12, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Random notification chime every minute or so
2 participants