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