improved document visibility handling
This commit is contained in:
parent
05cf7cc081
commit
57100baf7c
@ -570,28 +570,18 @@ export default {
|
||||
window.addEventListener("online", this.updateOnlineStatus)
|
||||
window.addEventListener("offline", this.updateOnlineStatus)
|
||||
|
||||
addEventListener("visibilitychange", (event) => {useShoppingListStore().autosync_has_focus = (document.visibilityState === 'visible')});
|
||||
|
||||
this.$i18n.locale = window.CUSTOM_LOCALE
|
||||
|
||||
this.shopping_list_store.refreshFromAPI()
|
||||
useUserPreferenceStore().loadUserSettings()
|
||||
useUserPreferenceStore().loadDeviceSettings()
|
||||
this.autoSyncLoop()
|
||||
this.setupFocusMonitor()
|
||||
|
||||
},
|
||||
methods: {
|
||||
useUserPreferenceStore,
|
||||
useShoppingListStore,
|
||||
|
||||
/**
|
||||
* setup interval checking for focus every 1000ms and updating the store variable
|
||||
*/
|
||||
setupFocusMonitor: function () {
|
||||
setInterval(() => {
|
||||
useShoppingListStore().autosync_has_focus = document.hasFocus()
|
||||
}, 1000);
|
||||
|
||||
},
|
||||
/**
|
||||
* recursive function calling autosync after set amount of time has passed
|
||||
*/
|
||||
|
@ -26,8 +26,8 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
||||
// internal
|
||||
currently_updating: false,
|
||||
last_autosync: null,
|
||||
autosync_has_focus: true,
|
||||
undo_stack: [],
|
||||
autosync_has_focus: false,
|
||||
|
||||
// constants
|
||||
GROUP_CATEGORY: 'food.supermarket_category.name',
|
||||
|
Loading…
Reference in New Issue
Block a user