From db9444aaa4e2e08f00313e9ba8b95ee358ccc6db Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Tue, 6 Jan 2026 18:27:56 +0100 Subject: [PATCH] refactor: expose actions through context --- .../input/delay-input/DelayInput.tsx | 7 +- .../client/src/common/hooks/useEntryAction.ts | 52 ++++++++----- apps/client/src/features/rundown/Rundown.tsx | 4 +- .../src/features/rundown/RundownExport.tsx | 75 ++++++++++--------- .../features/rundown/common/TitleEditor.tsx | 4 +- .../rundown/context/RundownActionsContext.tsx | 24 ++++++ .../rundown/entry-editor/EventEditor.tsx | 4 +- .../rundown/entry-editor/GroupEditor.tsx | 4 +- .../rundown/entry-editor/MilestoneEditor.tsx | 4 +- .../composite/EventEditorTimes.tsx | 4 +- .../composite/EventEditorTitles.tsx | 4 +- .../composite/EventEditorTriggers.tsx | 6 +- .../quick-add-buttons/QuickAddButtons.tsx | 4 +- .../quick-add-cursor/QuickAddInline.tsx | 4 +- .../rundown/rundown-delay/RundownDelay.tsx | 4 +- .../rundown/rundown-event/RundownEvent.tsx | 4 +- .../composite/RundownEventPlayback.tsx | 4 +- .../rundown/rundown-group/RundownGroup.tsx | 4 +- .../rundown/rundown-header/RundownMenu.tsx | 4 +- .../rundown-milestone/RundownMilestone.tsx | 4 +- .../rundown/time-input-flow/TimeInputFlow.tsx | 4 +- 21 files changed, 138 insertions(+), 90 deletions(-) create mode 100644 apps/client/src/features/rundown/context/RundownActionsContext.tsx diff --git a/apps/client/src/common/components/input/delay-input/DelayInput.tsx b/apps/client/src/common/components/input/delay-input/DelayInput.tsx index 76870796a..7b8e699ab 100644 --- a/apps/client/src/common/components/input/delay-input/DelayInput.tsx +++ b/apps/client/src/common/components/input/delay-input/DelayInput.tsx @@ -1,7 +1,7 @@ import { KeyboardEvent, useEffect, useRef, useState } from 'react'; import { millisToString, parseUserTime } from 'ontime-utils'; -import { useEntryActions } from '../../../hooks/useEntryAction'; +import { useRundownEntryActions } from '../../../../features/rundown/context/RundownActionsContext'; import Input from '../input/Input'; import BlockRadio from './BlockRadio'; @@ -13,9 +13,8 @@ interface DelayInputProps { duration: number; } -export default function DelayInput(props: DelayInputProps) { - const { eventId, duration } = props; - const { updateEntry } = useEntryActions(); +export default function DelayInput({ eventId, duration }: DelayInputProps) { + const { updateEntry } = useRundownEntryActions(); const [value, setValue] = useState(''); const inputRef = useRef(null); diff --git a/apps/client/src/common/hooks/useEntryAction.ts b/apps/client/src/common/hooks/useEntryAction.ts index 0a19b2eef..16c6efefc 100644 --- a/apps/client/src/common/hooks/useEntryAction.ts +++ b/apps/client/src/common/hooks/useEntryAction.ts @@ -1,4 +1,4 @@ -import { useCallback } from 'react'; +import { useCallback, useMemo } from 'react'; import { useMutation, useQueryClient } from '@tanstack/react-query'; import { EntryId, @@ -840,22 +840,40 @@ export const useEntryActions = () => { [getCurrentRundownData, swapEventsMutation], ); - return { - addEntry, - applyDelay, - batchUpdateEvents, - clone, - deleteEntry, - deleteAllEntries, - ungroup, - getEntryById, - groupEntries, - move, - reorderEntry, - swapEvents, - updateEntry, - updateTimer, - }; + return useMemo( + () => ({ + addEntry, + applyDelay, + batchUpdateEvents, + clone, + deleteEntry, + deleteAllEntries, + ungroup, + getEntryById, + groupEntries, + move, + reorderEntry, + swapEvents, + updateEntry, + updateTimer, + }), + [ + addEntry, + applyDelay, + batchUpdateEvents, + clone, + deleteEntry, + deleteAllEntries, + ungroup, + getEntryById, + groupEntries, + move, + reorderEntry, + swapEvents, + updateEntry, + updateTimer, + ], + ); }; /** diff --git a/apps/client/src/features/rundown/Rundown.tsx b/apps/client/src/features/rundown/Rundown.tsx index 71baf82da..c2a3ae4f0 100644 --- a/apps/client/src/features/rundown/Rundown.tsx +++ b/apps/client/src/features/rundown/Rundown.tsx @@ -32,13 +32,13 @@ import { reorderArray, } from 'ontime-utils'; -import { useEntryActions } from '../../common/hooks/useEntryAction'; import useFollowComponent from '../../common/hooks/useFollowComponent'; import { useRundownEditor } from '../../common/hooks/useSocket'; import { useEntryCopy } from '../../common/stores/entryCopyStore'; import { lastMetadataKey, RundownMetadataObject } from '../../common/utils/rundownMetadata'; import { AppMode, sessionKeys } from '../../ontimeConfig'; +import { useRundownEntryActions } from './context/RundownActionsContext'; import QuickAddButtons from './entry-editor/quick-add-buttons/QuickAddButtons'; import QuickAddInline from './entry-editor/quick-add-cursor/QuickAddInline'; import RundownGroup from './rundown-group/RundownGroup'; @@ -72,7 +72,7 @@ export default function Rundown({ data, rundownMetadata }: RundownProps) { }); const collapsedGroupSet = useMemo(() => new Set(collapsedGroups), [collapsedGroups]); - const { addEntry, clone, deleteEntry, move, reorderEntry } = useEntryActions(); + const { addEntry, clone, deleteEntry, move, reorderEntry } = useRundownEntryActions(); const setEntryCopyId = useEntryCopy((state) => state.setEntryCopyId); // cursor diff --git a/apps/client/src/features/rundown/RundownExport.tsx b/apps/client/src/features/rundown/RundownExport.tsx index 0f42800bc..cc0c41dff 100644 --- a/apps/client/src/features/rundown/RundownExport.tsx +++ b/apps/client/src/features/rundown/RundownExport.tsx @@ -5,12 +5,14 @@ import * as Editor from '../../common/components/editor-utils/EditorUtils'; import ErrorBoundary from '../../common/components/error-boundary/ErrorBoundary'; import ViewNavigationMenu from '../../common/components/navigation-menu/ViewNavigationMenu'; import ProtectRoute from '../../common/components/protect-route/ProtectRoute'; +import { useEntryActions } from '../../common/hooks/useEntryAction'; import { useIsSmallDevice } from '../../common/hooks/useIsSmallDevice'; import { handleLinks } from '../../common/utils/linkUtils'; import { cx } from '../../common/utils/styleUtils'; import { getIsNavigationLocked } from '../../externals'; import { AppMode, sessionKeys } from '../../ontimeConfig'; +import { RundownActionsProvider } from './context/RundownActionsContext'; import RundownEntryEditor from './entry-editor/RundownEntryEditor'; import FinderPlacement from './placements/FinderPlacement'; import { RundownContextMenu } from './rundown-context-menu/RundownContextMenu'; @@ -31,52 +33,57 @@ function RundownExport() { defaultValue: 'list', }); const isSmallDevice = useIsSmallDevice(); + const entryActions = useEntryActions(); if (isSmallDevice && isExtracted) { return ( - -
- - -
- - - - + + +
+ + +
+ + + + +
-
- + + ); } const hideSideBar = (isExtracted && editorMode === 'run') || viewMode === 'table'; return ( - -
- - {isExtracted && } -
- - - {!isExtracted && handleLinks('rundown', event)} />} - - - - - {!hideSideBar && ( -
+ + +
+ + {isExtracted && } +
+ - + {!isExtracted && handleLinks('rundown', event)} />} + + -
- )} + + {!hideSideBar && ( +
+ + + +
+ )} +
-
- + + ); } diff --git a/apps/client/src/features/rundown/common/TitleEditor.tsx b/apps/client/src/features/rundown/common/TitleEditor.tsx index 52785ffad..5199bd866 100644 --- a/apps/client/src/features/rundown/common/TitleEditor.tsx +++ b/apps/client/src/features/rundown/common/TitleEditor.tsx @@ -2,8 +2,8 @@ import { useCallback, useRef } from 'react'; import Input from '../../../common/components/input/input/Input'; import useReactiveTextInput from '../../../common/components/input/text-input/useReactiveTextInput'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { cx } from '../../../common/utils/styleUtils'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import style from './TitleEditor.module.scss'; @@ -15,7 +15,7 @@ interface TitleEditorProps { } export default function TitleEditor({ title, entryId, placeholder, className }: TitleEditorProps) { - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const ref = useRef(null); const submitCallback = useCallback( (text: string) => { diff --git a/apps/client/src/features/rundown/context/RundownActionsContext.tsx b/apps/client/src/features/rundown/context/RundownActionsContext.tsx new file mode 100644 index 000000000..12aa75f84 --- /dev/null +++ b/apps/client/src/features/rundown/context/RundownActionsContext.tsx @@ -0,0 +1,24 @@ +import { createContext, PropsWithChildren, useContext } from 'react'; + +import { useEntryActions } from '../../../common/hooks/useEntryAction'; + +type EntryActionsContextValue = ReturnType; +const RundownActionsContext = createContext(null); + +interface RundownActionsProviderProps extends PropsWithChildren { + actions: EntryActionsContextValue; +} + +export function RundownActionsProvider({ children, actions }: RundownActionsProviderProps) { + return {children}; +} + +export function useRundownEntryActions(): EntryActionsContextValue { + const context = useContext(RundownActionsContext); + + if (!context) { + throw new Error('useRundownEntryActions must be used within RundownActionsProvider'); + } + + return context; +} diff --git a/apps/client/src/features/rundown/entry-editor/EventEditor.tsx b/apps/client/src/features/rundown/entry-editor/EventEditor.tsx index bba24fca2..2a2a472bb 100644 --- a/apps/client/src/features/rundown/entry-editor/EventEditor.tsx +++ b/apps/client/src/features/rundown/entry-editor/EventEditor.tsx @@ -3,8 +3,8 @@ import { OntimeEvent } from 'ontime-types'; import * as Editor from '../../../common/components/editor-utils/EditorUtils'; import AppLink from '../../../common/components/link/app-link/AppLink'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import useCustomFields from '../../../common/hooks-query/useCustomFields'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import EntryEditorCustomFields from './composite/EventEditorCustomFields'; import EventEditorTimes from './composite/EventEditorTimes'; @@ -22,7 +22,7 @@ interface EventEditorProps { export default function EventEditor({ event }: EventEditorProps) { const { data: customFields } = useCustomFields(); - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const isEditor = window.location.pathname.includes('editor'); diff --git a/apps/client/src/features/rundown/entry-editor/GroupEditor.tsx b/apps/client/src/features/rundown/entry-editor/GroupEditor.tsx index cad96468b..47d4d36d4 100644 --- a/apps/client/src/features/rundown/entry-editor/GroupEditor.tsx +++ b/apps/client/src/features/rundown/entry-editor/GroupEditor.tsx @@ -5,11 +5,11 @@ import { millisToString } from 'ontime-utils'; import * as Editor from '../../../common/components/editor-utils/EditorUtils'; import SwatchSelect from '../../../common/components/input/colour-input/SwatchSelect'; import AppLink from '../../../common/components/link/app-link/AppLink'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import useCustomFields from '../../../common/hooks-query/useCustomFields'; import { getOffsetState } from '../../../common/utils/offset'; import { cx, enDash, timerPlaceholder } from '../../../common/utils/styleUtils'; import TextLikeInput from '../../../views/cuesheet/cuesheet-table/cuesheet-table-elements/TextLikeInput'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import EntryEditorCustomFields from './composite/EventEditorCustomFields'; import EventTextArea from './composite/EventTextArea'; @@ -28,7 +28,7 @@ interface GroupEditorProps { export default function GroupEditor({ group }: GroupEditorProps) { const { data: customFields } = useCustomFields(); - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const handleSubmit = useCallback( (field: GroupEditorUpdateTextFields | GroupEditorUpdateMaybeNumberFields, value: string | MaybeNumber) => { diff --git a/apps/client/src/features/rundown/entry-editor/MilestoneEditor.tsx b/apps/client/src/features/rundown/entry-editor/MilestoneEditor.tsx index 39a2e6c46..9eb03e61c 100644 --- a/apps/client/src/features/rundown/entry-editor/MilestoneEditor.tsx +++ b/apps/client/src/features/rundown/entry-editor/MilestoneEditor.tsx @@ -5,8 +5,8 @@ import * as Editor from '../../../common/components/editor-utils/EditorUtils'; import SwatchSelect from '../../../common/components/input/colour-input/SwatchSelect'; import Input from '../../../common/components/input/input/Input'; import AppLink from '../../../common/components/link/app-link/AppLink'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import useCustomFields from '../../../common/hooks-query/useCustomFields'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import EntryEditorCustomFields from './composite/EventEditorCustomFields'; import EventTextArea from './composite/EventTextArea'; @@ -22,7 +22,7 @@ interface MilestoneEditorProps { } export default function MilestoneEditor({ milestone }: MilestoneEditorProps) { const { data: customFields } = useCustomFields(); - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const handleSubmit = useCallback( (field: MilestoneEditorUpdateTextFields, value: string) => { diff --git a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTimes.tsx b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTimes.tsx index fd1647c4f..89b975267 100644 --- a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTimes.tsx +++ b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTimes.tsx @@ -8,8 +8,8 @@ import TimeInput from '../../../../common/components/input/time-input/TimeInput' import Select from '../../../../common/components/select/Select'; import Switch from '../../../../common/components/switch/Switch'; import Tooltip from '../../../../common/components/tooltip/Tooltip'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; import { millisToDelayString } from '../../../../common/utils/dateConfig'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import TimeInputFlow from '../../time-input-flow/TimeInputFlow'; import style from '../EntryEditor.module.scss'; @@ -46,7 +46,7 @@ function EventEditorTimes({ timeWarning, timeDanger, }: EventEditorTimesProps) { - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const handleSubmit = (field: HandledActions, value: string | boolean) => { if (field === 'countToEnd') { diff --git a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTitles.tsx b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTitles.tsx index 09f65495d..58507ccef 100644 --- a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTitles.tsx +++ b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTitles.tsx @@ -5,7 +5,7 @@ import * as Editor from '../../../../common/components/editor-utils/EditorUtils' import SwatchSelect from '../../../../common/components/input/colour-input/SwatchSelect'; import Input from '../../../../common/components/input/input/Input'; import Switch from '../../../../common/components/switch/Switch'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import EventTextArea from './EventTextArea'; import EntryEditorTextInput from './EventTextInput'; @@ -23,7 +23,7 @@ interface EventEditorTitlesProps { export default memo(EventEditorTitles); function EventEditorTitles({ eventId, cue, flag, title, note, colour }: EventEditorTitlesProps) { - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const cueSubmitHandler = (_field: string, newValue: string) => { updateEntry({ id: eventId, cue: sanitiseCue(newValue) }); diff --git a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTriggers.tsx b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTriggers.tsx index da60bf3cc..e7d815622 100644 --- a/apps/client/src/features/rundown/entry-editor/composite/EventEditorTriggers.tsx +++ b/apps/client/src/features/rundown/entry-editor/composite/EventEditorTriggers.tsx @@ -8,8 +8,8 @@ import IconButton from '../../../../common/components/buttons/IconButton'; import Select from '../../../../common/components/select/Select'; import Tag from '../../../../common/components/tag/Tag'; import Tooltip from '../../../../common/components/tooltip/Tooltip'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; import useAutomationSettings from '../../../../common/hooks-query/useAutomationSettings'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import { eventTriggerOptions } from './eventTrigger.constants'; @@ -38,7 +38,7 @@ interface EventTriggerFormProps { function EventTriggerForm({ eventId, triggers }: EventTriggerFormProps) { const { data: automationSettings } = useAutomationSettings(); - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const [automationId, setAutomationId] = useState(undefined); const [cycleValue, setCycleValue] = useState(TimerLifeCycle.onStart); @@ -123,7 +123,7 @@ interface ExistingEventTriggersProps { } function ExistingEventTriggers({ eventId, triggers }: ExistingEventTriggersProps) { - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const { data: automationSettings } = useAutomationSettings(); const handleDelete = useCallback( diff --git a/apps/client/src/features/rundown/entry-editor/quick-add-buttons/QuickAddButtons.tsx b/apps/client/src/features/rundown/entry-editor/quick-add-buttons/QuickAddButtons.tsx index b58e11907..dee4684b3 100644 --- a/apps/client/src/features/rundown/entry-editor/quick-add-buttons/QuickAddButtons.tsx +++ b/apps/client/src/features/rundown/entry-editor/quick-add-buttons/QuickAddButtons.tsx @@ -4,8 +4,8 @@ import { Toolbar } from '@base-ui/react/toolbar'; import { MaybeString, SupportedEntry } from 'ontime-types'; import Button from '../../../../common/components/buttons/Button'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; import { cx } from '../../../../common/utils/styleUtils'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import style from './QuickAddButtons.module.scss'; @@ -17,7 +17,7 @@ interface QuickAddButtonsProps { export default memo(QuickAddButtons); function QuickAddButtons({ previousEventId, parentGroup, backgroundColor }: QuickAddButtonsProps) { - const { addEntry } = useEntryActions(); + const { addEntry } = useRundownEntryActions(); const addEvent = () => { addEntry( diff --git a/apps/client/src/features/rundown/entry-editor/quick-add-cursor/QuickAddInline.tsx b/apps/client/src/features/rundown/entry-editor/quick-add-cursor/QuickAddInline.tsx index 3d00a9435..712082b2c 100644 --- a/apps/client/src/features/rundown/entry-editor/quick-add-cursor/QuickAddInline.tsx +++ b/apps/client/src/features/rundown/entry-editor/quick-add-cursor/QuickAddInline.tsx @@ -4,7 +4,7 @@ import { MaybeString, SupportedEntry } from 'ontime-types'; import IconButton from '../../../../common/components/buttons/IconButton'; import { DropdownMenu } from '../../../../common/components/dropdown-menu/DropdownMenu'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import style from './QuickAddInline.module.scss'; @@ -16,7 +16,7 @@ interface QuickAddInlineProps { export default memo(QuickAddInline); function QuickAddInline({ referenceEntryId, parentGroup, placement }: QuickAddInlineProps) { - const { addEntry } = useEntryActions(); + const { addEntry } = useRundownEntryActions(); const handleAddEntry = (type: SupportedEntry) => { if (placement === 'before') { diff --git a/apps/client/src/features/rundown/rundown-delay/RundownDelay.tsx b/apps/client/src/features/rundown/rundown-delay/RundownDelay.tsx index 2f0f32cc0..9b020afa5 100644 --- a/apps/client/src/features/rundown/rundown-delay/RundownDelay.tsx +++ b/apps/client/src/features/rundown/rundown-delay/RundownDelay.tsx @@ -6,8 +6,8 @@ import { OntimeDelay } from 'ontime-types'; import Button from '../../../common/components/buttons/Button'; import DelayInput from '../../../common/components/input/delay-input/DelayInput'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { cx } from '../../../common/utils/styleUtils'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import style from './RundownDelay.module.scss'; @@ -19,7 +19,7 @@ interface RundownDelayProps { export default function RundownDelay({ data, hasCursor }: RundownDelayProps) { 'use memo'; - const { applyDelay, deleteEntry } = useEntryActions(); + const { applyDelay, deleteEntry } = useRundownEntryActions(); const handleRef = useRef(null); const { diff --git a/apps/client/src/features/rundown/rundown-event/RundownEvent.tsx b/apps/client/src/features/rundown/rundown-event/RundownEvent.tsx index 7e0b42ae7..a7564d7c9 100644 --- a/apps/client/src/features/rundown/rundown-event/RundownEvent.tsx +++ b/apps/client/src/features/rundown/rundown-event/RundownEvent.tsx @@ -16,8 +16,8 @@ import { EndAction, EntryId, Playback, TimerType, TimeStrategy } from 'ontime-ty import { isPlaybackActive } from 'ontime-utils'; import { useContextMenu } from '../../../common/hooks/useContextMenu'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { cx, getAccessibleColour } from '../../../common/utils/styleUtils'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import { useEventIdSwapping } from '../useEventIdSwapping'; import { getSelectionMode, useEventSelection } from '../useEventSelection'; @@ -97,7 +97,7 @@ export default function RundownEvent({ const setSelectedEventId = useEventIdSwapping((state) => state.setSelectedEventId); const clearSelectedEventId = useEventIdSwapping((state) => state.clearSelectedEventId); - const { updateEntry, batchUpdateEvents, clone, deleteEntry, groupEntries, swapEvents } = useEntryActions(); + const { updateEntry, batchUpdateEvents, clone, deleteEntry, groupEntries, swapEvents } = useRundownEntryActions(); const isSelected = useEventSelection((state) => state.selectedEvents.has(eventId)); const unselect = useEventSelection((state) => state.unselect); diff --git a/apps/client/src/features/rundown/rundown-event/composite/RundownEventPlayback.tsx b/apps/client/src/features/rundown/rundown-event/composite/RundownEventPlayback.tsx index 21514b0dc..fa8ebac1c 100644 --- a/apps/client/src/features/rundown/rundown-event/composite/RundownEventPlayback.tsx +++ b/apps/client/src/features/rundown/rundown-event/composite/RundownEventPlayback.tsx @@ -3,8 +3,8 @@ import { IoPause, IoPlay, IoReload, IoRemoveCircle, IoRemoveCircleOutline } from import IconButton from '../../../../common/components/buttons/IconButton'; import Tooltip from '../../../../common/components/tooltip/Tooltip'; -import { useEntryActions } from '../../../../common/hooks/useEntryAction'; import { setEventPlayback } from '../../../../common/hooks/useSocket'; +import { useRundownEntryActions } from '../../context/RundownActionsContext'; import style from '../RundownEvent.module.scss'; @@ -26,7 +26,7 @@ function RundownEventPlayback({ loaded, disablePlayback, }: RundownEventPlaybackProps) { - const { updateEntry } = useEntryActions(); + const { updateEntry } = useRundownEntryActions(); const toggleSkip = (event: MouseEvent) => { event.stopPropagation(); diff --git a/apps/client/src/features/rundown/rundown-group/RundownGroup.tsx b/apps/client/src/features/rundown/rundown-group/RundownGroup.tsx index d1f6c1c7b..de25b8f1c 100644 --- a/apps/client/src/features/rundown/rundown-group/RundownGroup.tsx +++ b/apps/client/src/features/rundown/rundown-group/RundownGroup.tsx @@ -14,11 +14,11 @@ import { MILLIS_PER_MINUTE, millisToString } from 'ontime-utils'; import IconButton from '../../../common/components/buttons/IconButton'; import { useContextMenu } from '../../../common/hooks/useContextMenu'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { getOffsetState } from '../../../common/utils/offset'; import { cx, getAccessibleColour, timerPlaceholder } from '../../../common/utils/styleUtils'; import { formatDuration } from '../../../common/utils/time'; import TitleEditor from '../common/TitleEditor'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import { canDrop } from '../rundown.utils'; import { useEventSelection } from '../useEventSelection'; @@ -36,7 +36,7 @@ export default function RundownGroup({ data, hasCursor, collapsed, onCollapse }: 'use memo'; const handleRef = useRef(null); - const { clone, ungroup, deleteEntry } = useEntryActions(); + const { clone, ungroup, deleteEntry } = useRundownEntryActions(); const setSingleEntrySelection = useEventSelection((state) => state.setSingleEntrySelection); const selectedEvents = useEventSelection((state) => state.selectedEvents); diff --git a/apps/client/src/features/rundown/rundown-header/RundownMenu.tsx b/apps/client/src/features/rundown/rundown-header/RundownMenu.tsx index f39c4b43e..8aef5e700 100644 --- a/apps/client/src/features/rundown/rundown-header/RundownMenu.tsx +++ b/apps/client/src/features/rundown/rundown-header/RundownMenu.tsx @@ -5,8 +5,8 @@ import { useDisclosure, useSessionStorage } from '@mantine/hooks'; import Button from '../../../common/components/buttons/Button'; import Dialog from '../../../common/components/dialog/Dialog'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { AppMode, sessionKeys } from '../../../ontimeConfig'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import { useEventSelection } from '../useEventSelection'; import style from './RundownHeader.module.scss'; @@ -20,7 +20,7 @@ function RundownMenu() { key: sessionKeys.editorMode, defaultValue: AppMode.Edit, }); - const { deleteAllEntries } = useEntryActions(); + const { deleteAllEntries } = useRundownEntryActions(); const deleteAll = useCallback(() => { deleteAllEntries(); diff --git a/apps/client/src/features/rundown/rundown-milestone/RundownMilestone.tsx b/apps/client/src/features/rundown/rundown-milestone/RundownMilestone.tsx index 9626a2bbc..2edda1f78 100644 --- a/apps/client/src/features/rundown/rundown-milestone/RundownMilestone.tsx +++ b/apps/client/src/features/rundown/rundown-milestone/RundownMilestone.tsx @@ -7,8 +7,8 @@ import { EntryId } from 'ontime-types'; import Input from '../../../common/components/input/input/Input'; import useReactiveTextInput from '../../../common/components/input/text-input/useReactiveTextInput'; import { useContextMenu } from '../../../common/hooks/useContextMenu'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; import { cx, getAccessibleColour } from '../../../common/utils/styleUtils'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import { useEventSelection } from '../useEventSelection'; import style from './RundownMilestone.module.scss'; @@ -25,7 +25,7 @@ export default function RundownMilestone({ colour, cue, entryId, hasCursor, titl 'use memo'; const handleRef = useRef(null); - const { updateEntry, deleteEntry } = useEntryActions(); + const { updateEntry, deleteEntry } = useRundownEntryActions(); const selectedEvents = useEventSelection((state) => state.selectedEvents); const setSingleEntrySelection = useEventSelection((state) => state.setSingleEntrySelection); diff --git a/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx b/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx index 713a1f215..e9593ff47 100644 --- a/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx +++ b/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx @@ -7,7 +7,7 @@ import IconButton from '../../../common/components/buttons/IconButton'; import * as Editor from '../../../common/components/editor-utils/EditorUtils'; import TimeInput from '../../../common/components/input/time-input/TimeInput'; import Tooltip from '../../../common/components/tooltip/Tooltip'; -import { useEntryActions } from '../../../common/hooks/useEntryAction'; +import { useRundownEntryActions } from '../context/RundownActionsContext'; import TimeInputGroup from './TimeInputGroup'; @@ -37,7 +37,7 @@ function TimeInputFlow({ delay, showLabels, }: TimeInputFlowProps) { - const { updateEntry, updateTimer } = useEntryActions(); + const { updateEntry, updateTimer } = useRundownEntryActions(); // In sync with EventEditorTimes const handleSubmit = (field: TimeField, value: string) => {