pinafore/routes/_store/observers/notificationPermissionObservers.js
2018-11-05 08:28:38 -08:00

14 lines
411 B
JavaScript

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