@@ -335,19 +335,6 @@ export const useEntryActions = () => {
335335 [ getCurrentRundownData , updateEntryMutation ] ,
336336 ) ;
337337
338- const matchGroupDuration = useCallback ( async ( eventId : EntryId , groupId : EntryId ) => {
339- const rundown = queryClient . getQueryData < Rundown > ( RUNDOWN ) ;
340- if ( ! rundown ) return ;
341- const group = rundown . entries [ groupId ] ;
342- if ( ! group || ! isOntimeGroup ( group ) || group . targetDuration === null ) return ;
343- const event = rundown . entries [ eventId ] ;
344- if ( ! event || ! isOntimeEvent ( event ) ) return ;
345- const durationDiff = group . targetDuration - group . duration ;
346- const newDuration = event . duration + durationDiff ;
347- if ( newDuration < 0 ) return ;
348- updateTimer ( eventId , 'duration' , String ( newDuration / MILLIS_PER_SECOND ) + 's' , false ) ;
349- } , [ ] ) ;
350-
351338 /**
352339 * Updates time of existing event
353340 * @param eventId {EntryId} - id of the event
@@ -446,6 +433,24 @@ export const useEntryActions = () => {
446433 [ getCurrentRundownData , updateEntryMutation , queryClient ] ,
447434 ) ;
448435
436+ /**
437+ * Updates time of existing event so it satisfies the group target duration
438+ * @param eventId {EntryId} - id of the event
439+ * @param groupId {EntryId} - id of the enclosing group
440+ */
441+ const matchGroupDuration = useCallback ( async ( eventId : EntryId , groupId : EntryId ) => {
442+ const rundown = queryClient . getQueryData < Rundown > ( RUNDOWN ) ;
443+ if ( ! rundown ) return ;
444+ const group = rundown . entries [ groupId ] ;
445+ if ( ! group || ! isOntimeGroup ( group ) || group . targetDuration === null ) return ;
446+ const event = rundown . entries [ eventId ] ;
447+ if ( ! event || ! isOntimeEvent ( event ) ) return ;
448+ const durationDiff = group . targetDuration - group . duration ;
449+ const newDuration = event . duration + durationDiff ;
450+ if ( newDuration < 0 ) return ;
451+ updateTimer ( eventId , 'duration' , String ( newDuration / MILLIS_PER_SECOND ) + 's' , false ) ;
452+ } , [ queryClient , updateTimer ] ) ;
453+
449454 /**
450455 * Calls mutation to edit multiple events
451456 * @private
0 commit comments