Skip to content

Commit 76cb0fe

Browse files
committed
feat(event): refactor event editing to utilize session and repository
- Updated the _editEvent saga to check for session existence before editing events, enhancing security and data integrity. - Integrated the event repository for handling event edits, streamlining the process and improving code maintainability. - Removed direct API calls in favor of repository methods, aligning with best practices for data management.
1 parent e40ca95 commit 76cb0fe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

packages/web/src/ducks/events/sagas/saga.util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import {
66
Schema_Event,
77
} from "@core/types/event.types";
88
import dayjs from "@core/util/date/dayjs";
9+
import { session } from "@web/common/classes/Session";
10+
import { getEventRepository } from "@web/common/repositories/event/event.repository.util";
911
import {
1012
Schema_GridEvent,
1113
Schema_WebEvent,
1214
WithId,
1315
} from "@web/common/types/web.event.types";
1416
import { addId, assembleGridEvent } from "@web/common/utils/event/event.util";
1517
import { validateGridEvent } from "@web/common/validators/grid.event.validator";
16-
import { EventApi } from "@web/ducks/events/event.api";
1718
import { Payload_ConvertEvent } from "@web/ducks/events/event.types";
1819
import { selectEventById } from "@web/ducks/events/selectors/event.selectors";
1920
import { getDayEventsSlice } from "@web/ducks/events/slices/day.slice";
@@ -40,7 +41,9 @@ export function* _editEvent(
4041
gridEvent: Schema_GridEvent,
4142
params: { applyTo?: RecurringEventUpdateScope } = {},
4243
) {
43-
yield call(EventApi.edit, gridEvent._id, gridEvent, params);
44+
const sessionExists = yield call(session.doesSessionExist);
45+
const repository = getEventRepository(sessionExists);
46+
yield call([repository, repository.edit], gridEvent._id, gridEvent, params);
4447
}
4548

4649
export function* insertOptimisticEvent(

0 commit comments

Comments
 (0)