Skip to content

Commit

Permalink
refactor: make condition a variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktoast committed Jan 20, 2023
1 parent 0ca893c commit 0385829
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions apps/calendar/src/components/events/horizontalEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { dndSelector, optionsSelector, viewSelector } from '@src/selectors';
import { DraggingState } from '@src/slices/dnd';
import { isSameDate } from '@src/time/datetime';
import { passConditionalProp } from '@src/utils/preact';
import { isNil } from '@src/utils/type';
import { isPresent } from '@src/utils/type';

import type { CalendarColor } from '@t/options';

Expand Down Expand Up @@ -144,8 +144,9 @@ export function HorizontalEvent({
const eventContainerRef = useRef<HTMLDivElement>(null);

const { isReadOnly, id, calendarId } = uiModel.model;
const isDraggableEvent =
!isReadOnlyCalendar && !isReadOnly && isNil(resizingWidth) && isNil(movingLeft);

const isDraggingGuideEvent = isPresent(resizingWidth) || isPresent(movingLeft);
const isDraggableEvent = !isReadOnlyCalendar && !isReadOnly && !isDraggingGuideEvent;

const startDragEvent = (className: string) => {
setDraggingEventUIModel(uiModel);
Expand All @@ -160,8 +161,7 @@ export function HorizontalEvent({
if (
draggingState === DraggingState.DRAGGING &&
draggingEventUIModel?.cid() === uiModel.cid() &&
isNil(resizingWidth) &&
isNil(movingLeft)
!isDraggingGuideEvent
) {
setIsDraggingTarget(true);
} else {
Expand All @@ -170,7 +170,7 @@ export function HorizontalEvent({
});

useEffect(() => {
if (isNil(resizingWidth) && isNil(movingLeft)) {
if (!isDraggingGuideEvent) {
eventBus.fire('afterRenderEvent', uiModel.model.toEventObject());
}
// This effect is only for the first render.
Expand Down

0 comments on commit 0385829

Please sign in to comment.