Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix: All day event doesn't disappear after changing the week - Attempt #2 #185

Merged
merged 5 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/web/src/ducks/events/event.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ interface Payload_DeleteEvent {
}

export interface Payload_EditEvent {
applyTo?: Categories_Recur;
_id: string;
event: Schema_Event;
applyTo?: Categories_Recur;
shouldRemove?: boolean;
}

export interface Payload_GetPaginatedEvents extends Filters_Pagination {
Expand Down
11 changes: 8 additions & 3 deletions packages/web/src/ducks/events/sagas/event.sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,15 @@ export function* deleteSomedayEvent({ payload }: Action_DeleteEvent) {
}

export function* editEvent({ payload }: Action_EditEvent) {
const { _id, applyTo, event, shouldRemove } = payload;

try {
yield put(eventsEntitiesSlice.actions.edit(payload));
yield call(EventApi.edit, payload._id, payload.event, {
applyTo: payload.applyTo,
shouldRemove
? yield put(eventsEntitiesSlice.actions.delete({ _id }))
: yield put(eventsEntitiesSlice.actions.edit(payload));

yield call(EventApi.edit, _id, event, {
applyTo: applyTo,
});
tyler-dane marked this conversation as resolved.
Show resolved Hide resolved
yield put(editEventSlice.actions.success());
} catch (error) {
Expand Down
15 changes: 8 additions & 7 deletions packages/web/src/views/Calendar/hooks/draft/useDraftUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,17 @@ export const useDraftUtil = (

const submit = (draft: Schema_GridEvent) => {
const event = prepEvtBeforeSubmit(draft);
const { startOfView, endOfView } = weekProps.component;

const isExisting = event._id;
// include param for how to handle recurrences
if (isExisting) {
dispatch(
editEventSlice.actions.request({
_id: event._id,
event,
})
);
const isOutsideView =
!dayjs(event.startDate).isBetween(startOfView, endOfView, null, "[]") &&
!dayjs(event.endDate).isBetween(startOfView, endOfView, null, "[]");

const shouldRemove = isOutsideView ? true : false;
const payload = { _id: event._id, event, shouldRemove };
dispatch(editEventSlice.actions.request(payload));
} else {
dispatch(createEventSlice.actions.request(event));
}
Expand Down