only auto sync when window is focused
This commit is contained in:
parent
d1865b57f1
commit
4a7bd6a885
@ -575,10 +575,20 @@ export default {
|
|||||||
useUserPreferenceStore().loadUserSettings()
|
useUserPreferenceStore().loadUserSettings()
|
||||||
useUserPreferenceStore().loadDeviceSettings()
|
useUserPreferenceStore().loadDeviceSettings()
|
||||||
this.setupAutoSync()
|
this.setupAutoSync()
|
||||||
|
this.setupFocusMonitor()
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
useUserPreferenceStore,
|
useUserPreferenceStore,
|
||||||
useShoppingListStore,
|
useShoppingListStore,
|
||||||
|
|
||||||
|
setupFocusMonitor: function () {
|
||||||
|
setInterval(() => {
|
||||||
|
useShoppingListStore().autosync_has_focus = document.hasFocus()
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
setupAutoSync: function () {
|
setupAutoSync: function () {
|
||||||
// prevent setting up multiple loops on accident
|
// prevent setting up multiple loops on accident
|
||||||
// TODO should this just raise an error?
|
// TODO should this just raise an error?
|
||||||
|
@ -299,7 +299,8 @@
|
|||||||
"Warning": "Warning",
|
"Warning": "Warning",
|
||||||
"NoCategory": "No category selected.",
|
"NoCategory": "No category selected.",
|
||||||
"InheritWarning": "{food} is set to inherit, changes may not persist.",
|
"InheritWarning": "{food} is set to inherit, changes may not persist.",
|
||||||
"ShowDelayed": "Show Delayed Items",
|
"ShowDelayed": "Show delayed items",
|
||||||
|
"ShowRecentlyCompleted": "Show recently completed items",
|
||||||
"Completed": "Completed",
|
"Completed": "Completed",
|
||||||
"OfflineAlert": "You are offline, shopping list may not syncronize.",
|
"OfflineAlert": "You are offline, shopping list may not syncronize.",
|
||||||
"shopping_share": "Share Shopping List",
|
"shopping_share": "Share Shopping List",
|
||||||
|
@ -22,6 +22,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
|||||||
currently_updating: false,
|
currently_updating: false,
|
||||||
last_autosync: null,
|
last_autosync: null,
|
||||||
undo_stack: [],
|
undo_stack: [],
|
||||||
|
autosync_has_focus: false,
|
||||||
|
|
||||||
// constants
|
// constants
|
||||||
GROUP_CATEGORY: 'food.supermarket_category.name',
|
GROUP_CATEGORY: 'food.supermarket_category.name',
|
||||||
@ -163,7 +164,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
autosync() {
|
autosync() {
|
||||||
if (!this.currently_updating) {
|
if (!this.currently_updating && this.autosync_has_focus) {
|
||||||
console.log('running autosync')
|
console.log('running autosync')
|
||||||
this.currently_updating = true
|
this.currently_updating = true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user