From 55877d69a08a2139dabcd8ea8067b48a430acac0 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 28 Jan 2024 12:27:24 +0100 Subject: [PATCH] hopefully this really prevents multiple auto syncs even in HMR --- vue/src/apps/ShoppingListView/ShoppingListView.vue | 6 +++--- vue/src/stores/ShoppingListStore.js | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 386d2f1c..5063ba3a 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -570,11 +570,11 @@ export default { */ autoSyncLoop: function () { // this should not happen in production but sometimes in development with HMR - clearTimeout(this.autosync_id) - this.autosync_id = undefined + clearTimeout(useShoppingListStore().autosync_timeout_id) let timeout = Math.max(this.user_preference_store.user_settings.shopping_auto_sync, 1) * 1000 // if disabled (shopping_auto_sync=0) check again after 1 second if enabled - this.autosync_id = setTimeout(() => { + + useShoppingListStore().autosync_timeout_id = setTimeout(() => { if (this.user_preference_store.user_settings.shopping_auto_sync > 0) { this.shopping_list_store.autosync() } diff --git a/vue/src/stores/ShoppingListStore.js b/vue/src/stores/ShoppingListStore.js index fd805a7e..9edb0e98 100644 --- a/vue/src/stores/ShoppingListStore.js +++ b/vue/src/stores/ShoppingListStore.js @@ -27,6 +27,7 @@ export const useShoppingListStore = defineStore(_STORE_ID, { currently_updating: false, last_autosync: null, autosync_has_focus: true, + autosync_timeout_id: null, undo_stack: [], queue_timeout_id: undefined,