diff --git a/routes/_components/timeline/Timeline.html b/routes/_components/timeline/Timeline.html index 58b375f..7c56b0e 100644 --- a/routes/_components/timeline/Timeline.html +++ b/routes/_components/timeline/Timeline.html @@ -208,7 +208,9 @@ stop('handleItemIdsToAdd') } this.observe('itemIdsToAddStringified', itemIdsToAddStringified => { - scheduleIdleTask(handleItemIdsToAdd) + if (itemIdsToAddStringified) { + scheduleIdleTask(handleItemIdsToAdd) + } }) }, setupFocus() { diff --git a/routes/_store/notificationObservers.js b/routes/_store/notificationObservers.js index 79b4ccd..627dbdd 100644 --- a/routes/_store/notificationObservers.js +++ b/routes/_store/notificationObservers.js @@ -1,17 +1,19 @@ 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(() => { - if (hasNotifications) { - setFavicon('/favicon-alert.png') - } else { - setFavicon('/favicon.png') - } + setFavicon(hasNotifications ? '/favicon-alert.png' : '/favicon.png') + currentFaviconHasNotifications = !currentFaviconHasNotifications }) }) } diff --git a/routes/_store/store.js b/routes/_store/store.js index ea07766..cd2bcd0 100644 --- a/routes/_store/store.js +++ b/routes/_store/store.js @@ -41,10 +41,7 @@ export const store = new PinaforeStore({ mixins(PinaforeStore) computations(store) - -export function initStore () { - observers(store) -} +observers(store) if (process.browser && process.env.NODE_ENV !== 'production') { window.store = store // for debugging diff --git a/templates/main.js b/templates/main.js index 111593a..a745c0d 100644 --- a/templates/main.js +++ b/templates/main.js @@ -1,5 +1,4 @@ import { init } from 'sapper/runtime.js' -import { initStore } from '../routes/_store/store' import { loadPolyfills } from '../routes/_utils/loadPolyfills' import '../routes/_utils/offlineNotification' import '../routes/_utils/serviceWorkerClient' @@ -8,6 +7,5 @@ import '../routes/_utils/loadingMask' loadPolyfills().then(() => { // `routes` is an array of route objects injected by Sapper - initStore() init(document.querySelector('#sapper'), __routes__) })