1
0
mirror of https://github.com/TandoorRecipes/recipes.git synced 2026-01-11 17:16:59 -05:00

only auto sync when window is focused

This commit is contained in:
vabene1111
2024-01-14 22:16:38 +08:00
parent d1865b57f1
commit 4a7bd6a885
3 changed files with 14 additions and 2 deletions

View File

@@ -575,10 +575,20 @@ export default {
useUserPreferenceStore().loadUserSettings()
useUserPreferenceStore().loadDeviceSettings()
this.setupAutoSync()
this.setupFocusMonitor()
},
methods: {
useUserPreferenceStore,
useShoppingListStore,
setupFocusMonitor: function () {
setInterval(() => {
useShoppingListStore().autosync_has_focus = document.hasFocus()
}, 1000);
},
setupAutoSync: function () {
// prevent setting up multiple loops on accident
// TODO should this just raise an error?