mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-12 10:16:16 +01:00
20 lines
581 B
JavaScript
20 lines
581 B
JavaScript
import { setFavicon } from '../_utils/setFavicon'
|
|
import { scheduleIdleTask } from '../_utils/scheduleIdleTask'
|
|
|
|
let currentFaviconHasNotifications = false
|
|
|
|
export function notificationObservers (store) {
|
|
store.observe('hasNotifications', hasNotifications => {
|
|
if (!process.browser) {
|
|
return
|
|
}
|
|
if (currentFaviconHasNotifications === hasNotifications) {
|
|
return
|
|
}
|
|
scheduleIdleTask(() => {
|
|
setFavicon(hasNotifications ? '/favicon-alert.png' : '/favicon.png')
|
|
currentFaviconHasNotifications = !currentFaviconHasNotifications
|
|
})
|
|
})
|
|
}
|