forked from cybrespace/pinafore
20 lines
608 B
JavaScript
20 lines
608 B
JavaScript
import { setFavicon } from '../../_utils/setFavicon'
|
|
import { runMediumPriorityTask } from '../../_utils/runMediumPriorityTask'
|
|
|
|
let currentFaviconHasNotifications = false
|
|
|
|
export function notificationObservers (store) {
|
|
store.observe('hasNotifications', hasNotifications => {
|
|
if (!process.browser) {
|
|
return
|
|
}
|
|
runMediumPriorityTask(() => {
|
|
if (currentFaviconHasNotifications === hasNotifications) {
|
|
return
|
|
}
|
|
setFavicon(hasNotifications ? '/favicon-alert.png' : '/favicon.png')
|
|
currentFaviconHasNotifications = !currentFaviconHasNotifications
|
|
})
|
|
})
|
|
}
|