cursor fixes

- delete would use wrong index to relocate
- cursor uses eventId instead of eventIndex
- cursor would move on any item changes
This commit is contained in:
cv
2021-05-28 23:59:08 +02:00
parent 3d69dbab13
commit 81e3b0abbf
3 changed files with 34 additions and 29 deletions
+2 -2
View File
@@ -152,7 +152,7 @@ export const eventsPut = async (req, res) => {
}
try {
const eventIndex = data.events.findIndex((e) => e.id === req.body.id);
const eventIndex = data.events.findIndex((e) => e.id === eventId);
if (eventIndex === -1) {
res.status(400).send(`No Id found found`);
return;
@@ -164,7 +164,7 @@ export const eventsPut = async (req, res) => {
db.write();
// update timer
_updateTimersSingle(req.body.id, req.body);
_updateTimersSingle(eventId, req.body);
res.sendStatus(200);
} catch (error) {