2018-10-06 20:06:10 +00:00
|
|
|
export function notificationPermissionObservers (store) {
|
2018-11-05 16:28:38 +00:00
|
|
|
if (!process.browser || !navigator.permissions || !navigator.permissions.query) {
|
2018-10-06 20:06:10 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
navigator.permissions.query({ name: 'notifications' }).then(permission => {
|
|
|
|
store.set({ notificationPermission: permission.state })
|
|
|
|
|
|
|
|
permission.onchange = event => {
|
|
|
|
store.set({ notificationPermission: event.target.state })
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|