Fix double deletes

This commit is contained in:
Dominic Zimmer 2025-05-03 20:42:05 +02:00
parent c26512b90a
commit 24dc1f80b3

View File

@ -68,7 +68,8 @@ export type APIEndPoint = {
export const removeEntry = (store: Store, entry: ItemType): Store => { export const removeEntry = (store: Store, entry: ItemType): Store => {
const [storeIndex, dateString] = getToday(ensureToday(store))!; const [storeIndex, dateString] = getToday(ensureToday(store))!;
const today = store.entries[storeIndex]; const today = store.entries[storeIndex];
today.items = today.items.filter((item) => JSON.stringify(item) !== JSON.stringify(entry)); const indexHit = today.items.findIndex((item) => JSON.stringify(item) !== JSON.stringify(entry));
today.items = today.items.filter((_, i) => i !== indexHit);
store.entries[storeIndex] = today; store.entries[storeIndex] = today;
return store; return store;
} }