fixed duplication of values in recipe editor

This commit is contained in:
vabene1111
2022-05-11 19:31:44 +02:00
parent d9ebe3e0fb
commit dea83b5720

View File

@ -1030,11 +1030,11 @@ export default {
.listUnits(query, 1, this.options_limit)
.then((response) => {
this.units = response.data.results
let unique_units = this.units.map(u => u.name)
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) {
if (i.unit !== null && i.unit.id === undefined && !unique_units.includes(i.unit.name) ) {
this.units.push(i.unit)
}
}
@ -1054,11 +1054,11 @@ export default {
.listFoods(query, undefined, undefined, 1, this.options_limit)
.then((response) => {
this.foods = response.data.results
let unique_foods = this.foods.map(f => f.name)
if (this.recipe !== undefined) {
for (let s of this.recipe.steps) {
for (let i of s.ingredients) {
if (i.food !== null && i.food.id === undefined) {
if (i.food !== null && i.food.id === undefined && !unique_foods.includes(i.food.name)) {
this.foods.push(i.food)
}
}