feat: add multi-copy paste support

This commit is contained in:
Carlos Valente
2026-03-21 09:37:15 +01:00
parent 6a40c66a7b
commit e40a0eebec
19 changed files with 243 additions and 122 deletions
@@ -35,11 +35,13 @@ import { useCallback, useMemo } from 'react';
import { moveDown, moveUp, orderEntries } from '../../features/rundown/rundown.utils';
import { RUNDOWN } from '../api/constants';
import {
PastePayload,
ReorderEntry,
deleteEntries,
patchReorderEntry,
postAddEntry,
postCloneEntry,
postPasteEntries,
putBatchEditEvents,
putEditEntry,
requestApplyDelay,
@@ -270,6 +272,35 @@ export const useEntryActions = () => {
[cloneEntryMutation, getCurrentRundownData],
);
/**
* Calls mutation to paste entries
* @private
*/
const { mutateAsync: pasteEntriesMutation } = useMutation({
mutationFn: ([rundownId, data]: [string, PastePayload]) => postPasteEntries(rundownId, data),
onMutate: () => queryClient.cancelQueries({ queryKey: RUNDOWN }),
onSettled: () => queryClient.invalidateQueries({ queryKey: RUNDOWN }),
});
/**
* Paste entries from copy store into the active rundown
*/
const pasteEntries = useCallback(
async (data: PastePayload) => {
try {
const rundownId = getCurrentRundownData()?.id;
if (!rundownId) {
throw new Error('Rundown not initialised');
}
await pasteEntriesMutation([rundownId, data]);
} catch (error) {
logAxiosError('Error pasting entries', error);
}
},
[pasteEntriesMutation, getCurrentRundownData],
);
/**
* Calls mutation to update existing entry
* @private
@@ -919,6 +950,7 @@ export const useEntryActions = () => {
clone,
deleteEntry,
deleteAllEntries,
pasteEntries,
ungroup,
getEntryById,
groupEntries,
@@ -935,6 +967,7 @@ export const useEntryActions = () => {
clone,
deleteEntry,
deleteAllEntries,
pasteEntries,
ungroup,
getEntryById,
groupEntries,