bugfix on optimist updates

This commit is contained in:
cv
2021-04-21 23:17:23 +02:00
parent beb533d31d
commit e7f1fc8d04
@@ -30,13 +30,12 @@ export default function EventListWrapper() {
const previousEvents = queryClient.getQueryData(eventsNamespace);
// optimistically update object, temp ID until refetch
queryClient.setQueryData(eventsNamespace, (old) =>
old.splice(newEvent.order, 0, {
...newEvent,
id: new Date().toISOString(),
})
);
let optimistic = [...previousEvents];
optimistic.splice(newEvent.order, 0, {
...newEvent,
id: new Date().toISOString(),
});
queryClient.setQueryData(eventsNamespace, optimistic);
// Return a context with the previous and new todo
return { previousEvents };