[#48] fixed drag and drop waiting for api call to be done to show updated event
This commit is contained in:
@@ -15,6 +15,7 @@ import CalendarSelection from "./CalendarSelection";
|
|||||||
import {
|
import {
|
||||||
getCalendarDetailAsync,
|
getCalendarDetailAsync,
|
||||||
putEventAsync,
|
putEventAsync,
|
||||||
|
updateEventLocal,
|
||||||
} from "../../features/Calendars/CalendarSlice";
|
} from "../../features/Calendars/CalendarSlice";
|
||||||
import ImportAlert from "../../features/Events/ImportAlert";
|
import ImportAlert from "../../features/Events/ImportAlert";
|
||||||
import {
|
import {
|
||||||
@@ -330,8 +331,9 @@ export default function CalendarApp() {
|
|||||||
start: computedNewStart,
|
start: computedNewStart,
|
||||||
end: computedNewEnd,
|
end: computedNewEnd,
|
||||||
} as CalendarEvent;
|
} as CalendarEvent;
|
||||||
console.log(newEvent);
|
dispatch(
|
||||||
console.log(arg);
|
updateEventLocal({ calId: newEvent.calId, event: newEvent })
|
||||||
|
);
|
||||||
dispatch(
|
dispatch(
|
||||||
putEventAsync({ cal: calendars[newEvent.calId], newEvent })
|
putEventAsync({ cal: calendars[newEvent.calId], newEvent })
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -114,6 +114,13 @@ const CalendarSlice = createSlice({
|
|||||||
action.payload.eventUid
|
action.payload.eventUid
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
updateEventLocal: (
|
||||||
|
state,
|
||||||
|
action: PayloadAction<{ calId: string; event: CalendarEvent }>
|
||||||
|
) => {
|
||||||
|
const { calId, event } = action.payload;
|
||||||
|
state.list[calId].events[event.uid] = event;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder
|
builder
|
||||||
@@ -197,5 +204,6 @@ const CalendarSlice = createSlice({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { addEvent, removeEvent, createCalendar } = CalendarSlice.actions;
|
export const { addEvent, removeEvent, createCalendar, updateEventLocal } =
|
||||||
|
CalendarSlice.actions;
|
||||||
export default CalendarSlice.reducer;
|
export default CalendarSlice.reducer;
|
||||||
|
|||||||
Reference in New Issue
Block a user