feat: allow dissolving a block

This commit is contained in:
Carlos Valente
2025-05-16 21:01:24 +02:00
committed by arc-alex
parent 9edff55bd5
commit a1505606cf
7 changed files with 140 additions and 3 deletions
@@ -25,6 +25,7 @@ import {
ReorderEntry,
requestApplyDelay,
requestDeleteAll,
requestDissolveBlock,
requestEventSwap,
SwapEntry,
} from '../api/rundown';
@@ -514,6 +515,28 @@ export const useEntryActions = () => {
[_applyDelayMutation],
);
/**
* Calls mutation to dissolve a block
* @private
*/
const _dissolveBlockMutation = useMutation({
mutationFn: requestDissolveBlock,
onSettled: () => queryClient.invalidateQueries({ queryKey: RUNDOWN }),
});
/**
* Deletes a block and moves its events to the top level
*/
const dissolveBlock = useCallback(
async (blockId: EntryId) => {
try {
await _dissolveBlockMutation.mutateAsync(blockId);
} catch (error) {
logAxiosError('Error dissolving block', error);
}
},
[_dissolveBlockMutation],
);
/**
* Calls mutation to reorder an entry
* @private
@@ -663,6 +686,7 @@ export const useEntryActions = () => {
batchUpdateEvents,
deleteEntry,
deleteAllEntries,
dissolveBlock,
getEntryById,
reorderEntry,
swapEvents,