mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 22:24:11 +00:00
bugfix on optimist updates
This commit is contained in:
@@ -30,13 +30,12 @@ export default function EventListWrapper() {
|
|||||||
const previousEvents = queryClient.getQueryData(eventsNamespace);
|
const previousEvents = queryClient.getQueryData(eventsNamespace);
|
||||||
|
|
||||||
// optimistically update object, temp ID until refetch
|
// optimistically update object, temp ID until refetch
|
||||||
|
let optimistic = [...previousEvents];
|
||||||
queryClient.setQueryData(eventsNamespace, (old) =>
|
optimistic.splice(newEvent.order, 0, {
|
||||||
old.splice(newEvent.order, 0, {
|
...newEvent,
|
||||||
...newEvent,
|
id: new Date().toISOString(),
|
||||||
id: new Date().toISOString(),
|
});
|
||||||
})
|
queryClient.setQueryData(eventsNamespace, optimistic);
|
||||||
);
|
|
||||||
|
|
||||||
// Return a context with the previous and new todo
|
// Return a context with the previous and new todo
|
||||||
return { previousEvents };
|
return { previousEvents };
|
||||||
|
|||||||
Reference in New Issue
Block a user