mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-15 12:23:51 +00:00
feat: add multi-copy paste support
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user