From 24c301b141cebdb956b601eb51b05c292e4cfcb2 Mon Sep 17 00:00:00 2001 From: Martin Berka Date: Tue, 25 Jul 2023 23:51:17 +0200 Subject: [PATCH] =?UTF-8?q?Oprava=20ukl=C3=A1d=C3=A1n=C3=AD=20dat=20p?= =?UTF-8?q?=C5=99i=20zm=C4=9Bn=C4=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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); } } }