mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 15:09:10 +00:00
fix/141: enable applying negative delays (#142)
This commit is contained in:
@@ -286,33 +286,10 @@ export default function EventListWrapper() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'applyDelay':
|
case 'applyDelay':
|
||||||
// if delay <= 0 delete delay and next block
|
try {
|
||||||
if (payload.duration <= 0) {
|
await applyDelay.mutateAsync(payload.id);
|
||||||
try {
|
} catch (error) {
|
||||||
// look for block after
|
emitError(`Error applying delay: ${error.message}`);
|
||||||
let afterId = false;
|
|
||||||
let blockAfter = null;
|
|
||||||
for (const d of data) {
|
|
||||||
if (d.id === payload.id) afterId = true;
|
|
||||||
if (afterId && d.type === 'block') {
|
|
||||||
blockAfter = d.id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// delete delay
|
|
||||||
await deleteEvent.mutateAsync(payload.id);
|
|
||||||
// delete block after, if any
|
|
||||||
if (blockAfter) await deleteEvent.mutateAsync(blockAfter);
|
|
||||||
} catch (error) {
|
|
||||||
emitError(`Error applying delay: ${error.message}`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
await applyDelay.mutateAsync(payload.id);
|
|
||||||
} catch (error) {
|
|
||||||
emitError(`Error applying delay: ${error.message}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user