From 20adcc0e83d34d87c0834f0b1a427b9a384fa198 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 21 Jan 2022 16:44:03 +0100 Subject: [PATCH 1/3] fixed v2 autosync flickering --- .../apps/ShoppingListView/ShoppingListView.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/vue/src/apps/ShoppingListView/ShoppingListView.vue b/vue/src/apps/ShoppingListView/ShoppingListView.vue index 7432688e6..e5bbdd39d 100644 --- a/vue/src/apps/ShoppingListView/ShoppingListView.vue +++ b/vue/src/apps/ShoppingListView/ShoppingListView.vue @@ -715,7 +715,8 @@ export default { new_supermarket: {entrymode: false, value: undefined, editmode: undefined}, new_category: {entrymode: false, value: undefined}, autosync_id: undefined, - auto_sync_running: false, + 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, @@ -863,7 +864,7 @@ export default { window.addEventListener("offline", this.updateOnlineStatus) } this.autosync_id = setInterval(() => { - if (this.online && !this.auto_sync_running) { + if (this.online && !this.auto_sync_running && !this.auto_sync_blocked) { this.auto_sync_running = true this.getShoppingList(true) } @@ -1071,7 +1072,9 @@ export default { } this.loading = false } else { - this.mergeShoppingList(results.data) + if (!this.auto_sync_blocked) { + this.mergeShoppingList(results.data) + } } }) .catch((err) => { @@ -1195,6 +1198,7 @@ export default { }, updateChecked: function (update) { // when checking a sub item don't refresh the screen until all entries complete but change class to cross out + this.auto_sync_blocked = true let promises = [] update.entries.forEach((x) => { const id = x?.id ?? x @@ -1209,7 +1213,10 @@ export default { Vue.set(item, "completed_at", completed_at) }) - Promise.all(promises).catch((err) => { + Promise.all(promises).then(() => { + this.auto_sync_blocked = false + }).catch((err) => { + this.auto_sync_blocked = false console.log(err, err.response) StandardToasts.makeStandardToast(StandardToasts.FAIL_UPDATE) }) From f274f31e80f2db0b2ff349c6ca6c3132e328b24f Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 21 Jan 2022 16:56:47 +0100 Subject: [PATCH 2/3] fixed unit search on importer page --- cookbook/templates/url_import.html | 32 ++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/cookbook/templates/url_import.html b/cookbook/templates/url_import.html index 1b6de7102..8404527d8 100644 --- a/cookbook/templates/url_import.html +++ b/cookbook/templates/url_import.html @@ -908,28 +908,22 @@ // }) }, searchUnits: function (query) { - let apiFactory = new ApiApiFactory() - this.units_loading = true - apiFactory - .listUnits(query, 1, this.options_limit) - .then((response) => { - this.units = response.data.results - - if (this.recipe !== undefined) { - for (let s of this.recipe.steps) { - for (let i of s.ingredients) { - if (i.unit !== null && i.unit.id === undefined) { - this.units.push(i.unit) - } - } + this.$http.get("{% url 'dal_unit' %}" + '?q=' + query).then((response) => { + this.units = response.data.results; + if (this.recipe_data !== undefined) { + for (let x of Array.from(this.recipe_data.recipeIngredient)) { + if (x.unit !== null && x.unit.text !== '') { + this.units = this.units.filter(item => item.text !== x.unit.text) + this.units.push(x.unit) } } - this.units_loading = false - }) - .catch((err) => { - StandardToasts.makeStandardToast(StandardToasts.FAIL_FETCH) - }) + } + this.units_loading = false + }).catch((err) => { + console.log(err) + this.makeToast(gettext('Error'), gettext('There was an error loading a resource!') + err.bodyText, 'danger') + }) }, searchIngredients: function (query) { this.ingredients_loading = true From a30a27c755dbeb43e5cadccd05d95fcf6f575c66 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Fri, 21 Jan 2022 17:49:27 +0100 Subject: [PATCH 3/3] added keyword clicking to recipe view and fixed deleted keyword showing in search when passed via parameter --- .../RecipeSearchView/RecipeSearchView.vue | 209 ++++++++++++------ vue/src/components/KeywordsComponent.vue | 15 +- 2 files changed, 157 insertions(+), 67 deletions(-) diff --git a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue index 669af365e..7a66b7c4b 100644 --- a/vue/src/apps/RecipeSearchView/RecipeSearchView.vue +++ b/vue/src/apps/RecipeSearchView/RecipeSearchView.vue @@ -1,6 +1,6 @@