[#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 {
|
||||
getCalendarDetailAsync,
|
||||
putEventAsync,
|
||||
updateEventLocal,
|
||||
} from "../../features/Calendars/CalendarSlice";
|
||||
import ImportAlert from "../../features/Events/ImportAlert";
|
||||
import {
|
||||
@@ -330,8 +331,9 @@ export default function CalendarApp() {
|
||||
start: computedNewStart,
|
||||
end: computedNewEnd,
|
||||
} as CalendarEvent;
|
||||
console.log(newEvent);
|
||||
console.log(arg);
|
||||
dispatch(
|
||||
updateEventLocal({ calId: newEvent.calId, event: newEvent })
|
||||
);
|
||||
dispatch(
|
||||
putEventAsync({ cal: calendars[newEvent.calId], newEvent })
|
||||
);
|
||||
|
||||
@@ -114,6 +114,13 @@ const CalendarSlice = createSlice({
|
||||
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) => {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user