From 3ddf61c651676d8dfc645c8d5db4356db1717eb0 Mon Sep 17 00:00:00 2001 From: alex-arc Date: Fri, 3 Apr 2026 17:16:11 +0200 Subject: [PATCH] fill Dependency List --- .../client/src/common/hooks/useEntryAction.ts | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/apps/client/src/common/hooks/useEntryAction.ts b/apps/client/src/common/hooks/useEntryAction.ts index 2f002f952..20346e681 100644 --- a/apps/client/src/common/hooks/useEntryAction.ts +++ b/apps/client/src/common/hooks/useEntryAction.ts @@ -371,19 +371,6 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) { [getCurrentRundownData, updateEntryMutation], ); - const matchGroupDuration = useCallback(async (eventId: EntryId, groupId: EntryId) => { - const rundown = queryClient.getQueryData(RUNDOWN); - if (!rundown) return; - const group = rundown.entries[groupId]; - if (!group || !isOntimeGroup(group) || group.targetDuration === null) return; - const event = rundown.entries[eventId]; - if (!event || !isOntimeEvent(event)) return; - const durationDiff = group.targetDuration - group.duration; - const newDuration = event.duration + durationDiff; - if (newDuration < 0) return; - updateTimer(eventId, 'duration', String(newDuration / MILLIS_PER_SECOND) + 's', false); - }, []); - /** * Updates time of existing event * @param eventId {EntryId} - id of the event @@ -479,7 +466,28 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) { return previousEnd; } }, - [getCurrentRundownData, updateEntryMutation, queryClient], + [getCurrentRundownData, updateEntryMutation, queryClient, resolveCurrentRundownQueryKey], + ); + + /** + * Updates time of existing event so it satisfies the group target duration + * @param eventId {EntryId} - id of the event + * @param groupId {EntryId} - id of the enclosing group + */ + const matchGroupDuration = useCallback( + async (eventId: EntryId, groupId: EntryId) => { + const rundown = queryClient.getQueryData(resolveCurrentRundownQueryKey()); + if (!rundown) return; + const group = rundown.entries[groupId]; + if (!group || !isOntimeGroup(group) || group.targetDuration === null) return; + const event = rundown.entries[eventId]; + if (!event || !isOntimeEvent(event)) return; + const durationDiff = group.targetDuration - group.duration; + const newDuration = event.duration + durationDiff; + if (newDuration < 0) return; + updateTimer(eventId, 'duration', String(newDuration / MILLIS_PER_SECOND) + 's', false); + }, + [queryClient, updateTimer, resolveCurrentRundownQueryKey], ); /**