diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue
index 34debb2c..546af26c 100644
--- a/vue/src/apps/ShoppingListView/ShoppingListView.vue
+++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue
@@ -61,7 +61,7 @@
-
+
@@ -88,7 +88,7 @@
-
+
@@ -126,7 +126,7 @@
-
+
@@ -328,7 +328,7 @@
-
+
@@ -502,44 +502,19 @@ export default {
data() {
return {
- // this.Models and this.Actions inherited from ApiMixin
- items: [],
current_tab: 0,
- supermarkets: [],
- shopping_categories: [],
- show_undefined_categories: true,
- supermarket_categories_only: false,
- shopcat: null,
- delay: 0,
- generic_action: null,
- generic_model: null,
- ui: {
- entry_mode_simple: true,
- selected_supermarket: undefined,
- },
-
user_id: parseInt(localStorage.getItem('USER_ID')),
editing_supermarket_categories: [],
editing_supermarket: null,
new_supermarket: {entrymode: false, value: undefined, editmode: undefined},
new_category: {entrymode: false, value: undefined},
autosync_id: undefined,
- auto_sync_running: false, // track to not start a new sync before old one was finished
- auto_sync_blocked: false, // blocking auto sync while request to check item is still running
- show_delay: false,
- drag: false,
- show_modal: false,
- fields: ["checked", "amount", "category", "unit", "food", "recipe", "details"],
- loading: true,
- entrymode: false,
new_item: {amount: 1, unit: undefined, food: undefined, ingredient: undefined},
online: true,
new_recipe: {
id: undefined,
},
- add_recipe_servings: 1,
- shopping_list_height: '60vh',
shopping_list_store: useShoppingListStore(),
user_preference_store: useUserPreferenceStore(),
@@ -658,63 +633,6 @@ export default {
StandardToasts.makeStandardToast(this, StandardToasts.FAIL_DELETE, err)
})
},
- getShoppingList: function (autosync = false) {
- let params = {}
- params.supermarket = this.ui.selected_supermarket
-
- params.options = {query: {recent: 1}}
- if (autosync) {
- params.options.query["autosync"] = 1
- } else {
- this.loading = true
- }
- // this.genericAPI(this.Models.SHOPPING_LIST, this.Actions.LIST, params).then((results) => {
- // if (!autosync) {
- // if (results.data?.length) {
- // this.items = results.data
- // } else {
- // console.log("no data returned")
- // }
- // this.loading = false
- // } else {
- // if (!this.auto_sync_blocked) {
- // this.getSyncQueueLength().then((r) => {
- // if (r === 0) {
- // this.mergeShoppingList(results.data)
- // } else {
- // this.auto_sync_running = false
- // this.replaySyncQueue()
- // }
- // })
- // }
- // }
- // })
- // .catch((err) => {
- // if (!autosync) {
- // StandardToasts.makeStandardToast(this, StandardToasts.FAIL_FETCH, err)
- // }
- // })
- },
- mergeShoppingList: function (data) {
- this.items.map((x) =>
- data.map((y) => {
- if (y.id === x.id) {
- x.checked = y.checked
- return x
- }
- })
- )
- this.auto_sync_running = false
- let new_entries = data.map((x) => x.id).filter((y) => !this.items.map((z) => z.id).includes(y))
- if (new_entries.length > 0) {
- let api = new ApiApiFactory()
- new_entries.forEach((new_id) => {
- api.retrieveShoppingListEntry(new_id).then((result) => {
- this.items.push(result.data)
- })
- })
- }
- },
onHand: function (item) {
let api = new ApiApiFactory()
diff --git a/vue/src/stores/ShoppingListStore.js b/vue/src/stores/ShoppingListStore.js
index 42631ce7..1bd24dd1 100644
--- a/vue/src/stores/ShoppingListStore.js
+++ b/vue/src/stores/ShoppingListStore.js
@@ -171,7 +171,6 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
},
autosync() {
if (!this.currently_updating && this.autosync_has_focus) {
- console.log('running autosync')
this.currently_updating = true
let previous_autosync = this.last_autosync
@@ -183,15 +182,14 @@ export const useShoppingListStore = defineStore(_STORE_ID, {
}).then((r) => {
r.data.forEach((e) => {
// dont update stale client data
- //TODO validate the django datetime can be parsed in all browsers
- if (!(e.id in this.entries) || Date.parse(this.entries[e.id].updated_at) <= Date.parse(e.updated_at)) {
- console.log('updating entry ', e)
+ if (!(Object.keys(this.entries).includes(e.id.toString())) || Date.parse(this.entries[e.id].updated_at) < Date.parse(e.updated_at)) {
+ console.log('auto sync updating entry ', e)
Vue.set(this.entries, e.id, e)
}
})
this.currently_updating = false
}).catch((err) => {
- console.log('auto sync failed')
+ console.warn('auto sync failed')
this.currently_updating = false
})
}