mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 22:49:18 +00:00
refactor: swap maintains schedule
This commit is contained in:
@@ -525,6 +525,8 @@ export function swap({ rundown, fromId, toId }: SwapArgs): MutatingReturn {
|
|||||||
|
|
||||||
rundown.entries[fromId] = newFrom;
|
rundown.entries[fromId] = newFrom;
|
||||||
rundown.entries[toId] = newTo;
|
rundown.entries[toId] = newTo;
|
||||||
|
newFrom.revision++;
|
||||||
|
newTo.revision++;
|
||||||
|
|
||||||
setIsStale();
|
setIsStale();
|
||||||
return { newRundown: rundown, didMutate: true };
|
return { newRundown: rundown, didMutate: true };
|
||||||
|
|||||||
@@ -203,6 +203,7 @@ describe('swapEventData', () => {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
delay: 1,
|
delay: 1,
|
||||||
revision: 3,
|
revision: 3,
|
||||||
|
currentBlock: null,
|
||||||
} as OntimeEvent;
|
} as OntimeEvent;
|
||||||
const eventB = {
|
const eventB = {
|
||||||
id: '2',
|
id: '2',
|
||||||
@@ -212,6 +213,7 @@ describe('swapEventData', () => {
|
|||||||
duration: 2,
|
duration: 2,
|
||||||
delay: 2,
|
delay: 2,
|
||||||
revision: 7,
|
revision: 7,
|
||||||
|
currentBlock: 'testing',
|
||||||
} as OntimeEvent;
|
} as OntimeEvent;
|
||||||
|
|
||||||
const [newA, newB] = swapEventData(eventA, eventB);
|
const [newA, newB] = swapEventData(eventA, eventB);
|
||||||
@@ -223,7 +225,8 @@ describe('swapEventData', () => {
|
|||||||
timeEnd: 1,
|
timeEnd: 1,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
delay: 1,
|
delay: 1,
|
||||||
revision: 4,
|
revision: 3,
|
||||||
|
currentBlock: null,
|
||||||
});
|
});
|
||||||
expect(newB).toMatchObject({
|
expect(newB).toMatchObject({
|
||||||
id: '2',
|
id: '2',
|
||||||
@@ -232,7 +235,8 @@ describe('swapEventData', () => {
|
|||||||
timeEnd: 2,
|
timeEnd: 2,
|
||||||
duration: 2,
|
duration: 2,
|
||||||
delay: 2,
|
delay: 2,
|
||||||
revision: 8,
|
revision: 7,
|
||||||
|
currentBlock: 'testing',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -278,10 +278,13 @@ export const swapEventData = (eventA: OntimeEvent, eventB: OntimeEvent): [newA:
|
|||||||
timeEnd: eventA.timeEnd,
|
timeEnd: eventA.timeEnd,
|
||||||
duration: eventA.duration,
|
duration: eventA.duration,
|
||||||
linkStart: eventA.linkStart,
|
linkStart: eventA.linkStart,
|
||||||
|
currentBlock: eventA.currentBlock,
|
||||||
// keep schedule metadata
|
// keep schedule metadata
|
||||||
delay: eventA.delay,
|
delay: eventA.delay,
|
||||||
gap: eventA.gap,
|
gap: eventA.gap,
|
||||||
dayOffset: eventA.dayOffset,
|
dayOffset: eventA.dayOffset,
|
||||||
|
// keep revision number
|
||||||
|
revision: eventA.revision,
|
||||||
};
|
};
|
||||||
|
|
||||||
const newB = {
|
const newB = {
|
||||||
@@ -293,10 +296,13 @@ export const swapEventData = (eventA: OntimeEvent, eventB: OntimeEvent): [newA:
|
|||||||
timeEnd: eventB.timeEnd,
|
timeEnd: eventB.timeEnd,
|
||||||
duration: eventB.duration,
|
duration: eventB.duration,
|
||||||
linkStart: eventB.linkStart,
|
linkStart: eventB.linkStart,
|
||||||
|
currentBlock: eventB.currentBlock,
|
||||||
// keep schedule metadata
|
// keep schedule metadata
|
||||||
delay: eventB.delay,
|
delay: eventB.delay,
|
||||||
gap: eventB.gap,
|
gap: eventB.gap,
|
||||||
dayOffset: eventB.dayOffset,
|
dayOffset: eventB.dayOffset,
|
||||||
|
// keep revision number
|
||||||
|
revision: eventB.revision,
|
||||||
};
|
};
|
||||||
|
|
||||||
return [newA, newB];
|
return [newA, newB];
|
||||||
|
|||||||
Reference in New Issue
Block a user