@@ -15,6 +15,7 @@ import {
1515 _assembleGridEvent ,
1616 _createOptimisticGridEvent ,
1717 _editEvent ,
18+ getEventById ,
1819 normalizedEventsSchema ,
1920 replaceOptimisticId ,
2021} from "@web/ducks/events/sagas/saga.util" ;
@@ -55,14 +56,24 @@ export function* convertSomedayToCalendarEvent({
5556}
5657
5758export function * deleteSomedayEvent ( { payload } : Action_DeleteEvent ) {
59+ const event = yield * getEventById ( payload . _id ) ;
60+
5861 try {
5962 yield put ( eventsEntitiesSlice . actions . delete ( payload ) ) ;
6063
6164 yield call ( EventApi . delete , payload . _id , payload . applyTo ) ;
6265 } catch ( error ) {
63- yield put ( getSomedayEventsSlice . actions . error ( ) ) ;
66+ yield put (
67+ getSomedayEventsSlice . actions . error ( {
68+ __context : { reason : ( error as Error ) . message } ,
69+ } ) ,
70+ ) ;
6471 handleError ( error as Error ) ;
65- yield put ( getSomedayEventsSlice . actions . request ( ) ) ;
72+ yield put (
73+ eventsEntitiesSlice . actions . insert ( {
74+ [ payload . _id ] : event as Schema_Event ,
75+ } ) ,
76+ ) ;
6677 }
6778}
6879
@@ -92,17 +103,24 @@ export function* getSomedayEvents({ payload }: Action_GetEvents) {
92103 offset : res . offset ,
93104 } ) ,
94105 ) ;
95- // eslint-disable-next-line @typescript-eslint/no-unused-vars
96106 } catch ( error ) {
97- yield put ( getSomedayEventsSlice . actions . error ( ) ) ;
107+ yield put (
108+ getSomedayEventsSlice . actions . error ( {
109+ __context : { reason : ( error as Error ) . message } ,
110+ } ) ,
111+ ) ;
98112 }
99113}
100114
101115export function * reorderSomedayEvents ( { payload } : Action_Someday_Reorder ) {
102116 try {
103117 yield call ( EventApi . reorder , payload ) ;
104118 } catch ( error ) {
105- yield put ( getSomedayEventsSlice . actions . error ( ) ) ;
119+ yield put (
120+ getSomedayEventsSlice . actions . error ( {
121+ __context : { reason : ( error as Error ) . message } ,
122+ } ) ,
123+ ) ;
106124 handleError ( error as Error ) ;
107125 }
108126}
0 commit comments