Pinafore-Web-Client-Frontend/routes/_store/notificationObservers.js

18 lines
438 B
JavaScript
Raw Normal View History

2018-02-16 17:59:44 +01:00
import { setFavicon } from '../_utils/setFavicon'
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
export function notificationObservers (store) {
store.observe('hasNotifications', hasNotifications => {
if (!process.browser) {
return
}
scheduleIdleTask(() => {
if (hasNotifications) {
setFavicon('/favicon-alert.png')
} else {
setFavicon('/favicon.png')
}
})
})
2018-02-16 18:01:03 +01:00
}