diff --git a/server/src/service.ts b/server/src/service.ts index 7464389..e2968bc 100644 --- a/server/src/service.ts +++ b/server/src/service.ts @@ -255,6 +255,7 @@ export function removeChoices(login: string, location: Locations) { if (Object.keys(data.choices[location]).length === 0) { delete data.choices[location] } + db.set(today, data); } } return data; @@ -274,8 +275,10 @@ export function removeChoice(login: string, location: Locations, foodIndex: numb let data: ClientData = db.get(today); if (location in data.choices) { if (login in data.choices[location]) { - if (data.choices[location][login].includes(foodIndex)) { - data.choices[location][login].splice(foodIndex, 1) + const index = data.choices[location][login].indexOf(foodIndex); + if (index > -1) { + data.choices[location][login].splice(index, 1) + db.set(today, data); } } }