mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 23:19:09 +00:00
make event hit group target duration
This commit is contained in:
@@ -371,6 +371,19 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) {
|
|||||||
[getCurrentRundownData, updateEntryMutation],
|
[getCurrentRundownData, updateEntryMutation],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const matchGroupDuration = useCallback(async (eventId: EntryId, groupId: EntryId) => {
|
||||||
|
const rundown = queryClient.getQueryData<Rundown>(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
|
* Updates time of existing event
|
||||||
* @param eventId {EntryId} - id of the event
|
* @param eventId {EntryId} - id of the event
|
||||||
@@ -1009,6 +1022,7 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) {
|
|||||||
swapEvents,
|
swapEvents,
|
||||||
updateEntry,
|
updateEntry,
|
||||||
updateTimer,
|
updateTimer,
|
||||||
|
matchGroupDuration,
|
||||||
}),
|
}),
|
||||||
[
|
[
|
||||||
addEntry,
|
addEntry,
|
||||||
@@ -1026,6 +1040,7 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) {
|
|||||||
swapEvents,
|
swapEvents,
|
||||||
updateEntry,
|
updateEntry,
|
||||||
updateTimer,
|
updateTimer,
|
||||||
|
matchGroupDuration,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
IoTrash,
|
IoTrash,
|
||||||
IoUnlink,
|
IoUnlink,
|
||||||
} from 'react-icons/io5';
|
} from 'react-icons/io5';
|
||||||
import { TbFlagFilled, TbListNumbers } from 'react-icons/tb';
|
import { TbClockPin, TbFlagFilled, TbListNumbers } from 'react-icons/tb';
|
||||||
|
|
||||||
import { useEntryActionsContext } from '../../../common/context/EntryActionsContext';
|
import { useEntryActionsContext } from '../../../common/context/EntryActionsContext';
|
||||||
import { useContextMenu } from '../../../common/hooks/useContextMenu';
|
import { useContextMenu } from '../../../common/hooks/useContextMenu';
|
||||||
@@ -102,7 +102,8 @@ export default function RundownEvent({
|
|||||||
const clearSelectedEventId = useEventIdSwapping((state) => state.clearSelectedEventId);
|
const clearSelectedEventId = useEventIdSwapping((state) => state.clearSelectedEventId);
|
||||||
const openRenumberDialog = useRenumberCuesDialogStore((state) => state.onOpen);
|
const openRenumberDialog = useRenumberCuesDialogStore((state) => state.onOpen);
|
||||||
|
|
||||||
const { updateEntry, batchUpdateEvents, clone, deleteEntry, groupEntries, swapEvents } = useEntryActionsContext();
|
const { updateEntry, batchUpdateEvents, clone, deleteEntry, groupEntries, swapEvents, matchGroupDuration } =
|
||||||
|
useEntryActionsContext();
|
||||||
|
|
||||||
const isSelected = useEventSelection((state) => state.selectedEvents.has(eventId));
|
const isSelected = useEventSelection((state) => state.selectedEvents.has(eventId));
|
||||||
const unselect = useEventSelection((state) => state.unselect);
|
const unselect = useEventSelection((state) => state.unselect);
|
||||||
@@ -172,6 +173,16 @@ export default function RundownEvent({
|
|||||||
updateEntry({ id: eventId, flag: !flag });
|
updateEntry({ id: eventId, flag: !flag });
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'item',
|
||||||
|
label: 'Match Group Target Duration',
|
||||||
|
icon: TbClockPin,
|
||||||
|
onClick: () => {
|
||||||
|
if (!parent) return;
|
||||||
|
matchGroupDuration(eventId, parent);
|
||||||
|
},
|
||||||
|
disabled: !parent,
|
||||||
|
},
|
||||||
{ type: 'divider' },
|
{ type: 'divider' },
|
||||||
{
|
{
|
||||||
type: 'item',
|
type: 'item',
|
||||||
|
|||||||
Reference in New Issue
Block a user