pinafore/routes/_store/observers/notificationPermissionObservers.js
Sorin Davidoi e45af16bf9 Push notifications (#579)
* feat: Push notifications

* feat: Feature-detect push notifications support

* feat: Prompt user to reauthenticate when missing push scope

* fix(service-worker): Add tags to notifications

* feat: Push notification actions for mentions
2018-10-06 13:06:10 -07:00

14 lines
353 B
JavaScript

export function notificationPermissionObservers (store) {
if (!process.browser) {
return
}
navigator.permissions.query({ name: 'notifications' }).then(permission => {
store.set({ notificationPermission: permission.state })
permission.onchange = event => {
store.set({ notificationPermission: event.target.state })
}
})
}