1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 09:07:12 -05:00

improved document visibility handling

This commit is contained in:
vabene1111
2024-01-19 20:09:46 +08:00
parent 05cf7cc081
commit 57100baf7c
2 changed files with 3 additions and 13 deletions

View File

@@ -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
*/