chore: rename currentBlock > parent

This commit is contained in:
Carlos Valente
2025-04-13 20:57:54 +02:00
parent 6c8ddeec23
commit 0cae37d6c8
15 changed files with 90 additions and 90 deletions
@@ -15,7 +15,7 @@ describe('cloneEvent()', () => {
timeEnd: 10,
timerType: TimerType.CountDown,
timeStrategy: TimeStrategy.LockEnd,
currentBlock: 'test',
parent: 'test',
linkStart: false,
countToEnd: false,
endAction: EndAction.None,
@@ -46,7 +46,7 @@ describe('cloneEvent()', () => {
timeEnd: original.timeEnd,
timerType: original.timerType,
timeStrategy: original.timeStrategy,
currentBlock: 'test',
parent: 'test',
countToEnd: original.countToEnd,
linkStart: original.linkStart,
endAction: original.endAction,
@@ -23,7 +23,7 @@ export const cloneEvent = (event: OntimeEvent): ClonedEvent => {
isPublic: event.isPublic,
skip: event.skip,
colour: event.colour,
currentBlock: event.currentBlock,
parent: event.parent,
revision: 0,
delay: event.delay, // the events will be collocated, so having the same metadata is a good start
dayOffset: event.dayOffset,
+14 -14
View File
@@ -56,7 +56,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -85,7 +85,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -114,7 +114,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -143,7 +143,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -172,7 +172,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -219,7 +219,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -248,7 +248,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -277,7 +277,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -306,7 +306,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -335,7 +335,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -382,7 +382,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -411,7 +411,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -440,7 +440,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
@@ -469,7 +469,7 @@ export const demoDb: DatabaseModel = {
isPublic: true,
skip: false,
colour: '',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
dayOffset: 0,
+1 -1
View File
@@ -27,7 +27,7 @@ export const event: Omit<OntimeEvent, 'id' | 'cue'> = {
timeDanger: 60000,
custom: {},
// !==== RUNTIME METADATA ====! //
currentBlock: null,
parent: null,
revision: 0, // calculated at runtime
delay: 0, // calculated at runtime
dayOffset: 0, // calculated at runtime
@@ -536,9 +536,9 @@ describe('generate() v4', () => {
isFirstLinked: false,
numEvents: 3,
},
'100': { type: SupportedEvent.Event, currentBlock: '1' },
'200': { type: SupportedEvent.Event, currentBlock: '1' },
'300': { type: SupportedEvent.Event, currentBlock: '1' },
'100': { type: SupportedEvent.Event, parent: '1' },
'200': { type: SupportedEvent.Event, parent: '1' },
'300': { type: SupportedEvent.Event, parent: '1' },
});
});
@@ -567,7 +567,7 @@ describe('generate() v4', () => {
expect(generatedRundown.totalDuration).toBe(1200);
expect(generatedRundown.totalDelay).toBe(0);
expect(generatedRundown.entries).toMatchObject({
'0': { type: SupportedEvent.Event, currentBlock: null },
'0': { type: SupportedEvent.Event, parent: null },
'1': {
type: SupportedEvent.Block,
events: ['101', '102', '103'],
@@ -577,9 +577,9 @@ describe('generate() v4', () => {
isFirstLinked: false,
numEvents: 3,
},
'101': { currentBlock: '1', gap: 90, linkStart: false },
'102': { currentBlock: '1' },
'103': { currentBlock: '1' },
'101': { parent: '1', gap: 90, linkStart: false },
'102': { parent: '1' },
'103': { parent: '1' },
'2': {
type: SupportedEvent.Block,
events: ['201', '202', '203'],
@@ -223,7 +223,7 @@ function processEntry<T extends OntimeEntry>(
currentEntry.dayOffset = processedData.totalDays;
currentEntry.delay = 0; // this means we dont calculate delays or gaps for skipped events
currentEntry.gap = 0; // this means we dont calculate delays or gaps for skipped events
currentEntry.currentBlock = childOfBlock;
currentEntry.parent = childOfBlock;
// update rundown metadata, it only concerns playable events
if (isPlayableEvent(currentEntry)) {
@@ -39,7 +39,7 @@ describe('cellRequestFromEvent()', () => {
delay: 0,
gap: 0,
dayOffset: 0,
currentBlock: null,
parent: null,
revision: 0,
id: '1358',
timeWarning: 0,
@@ -85,7 +85,7 @@ describe('cellRequestFromEvent()', () => {
isPublic: false,
skip: false,
colour: 'red',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
gap: 0,
@@ -136,7 +136,7 @@ describe('cellRequestFromEvent()', () => {
isPublic: true,
skip: false,
colour: 'red',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
gap: 0,
@@ -189,7 +189,7 @@ describe('cellRequestFromEvent()', () => {
delay: 0,
gap: 0,
dayOffset: 0,
currentBlock: null,
parent: null,
revision: 0,
id: '1358',
timeWarning: 0,
@@ -222,7 +222,7 @@ describe('cellRequestFromEvent()', () => {
isPublic: true,
skip: false,
colour: 'red',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
gap: 0,
@@ -259,7 +259,7 @@ describe('cellRequestFromEvent()', () => {
isPublic: true,
skip: false,
colour: 'red',
currentBlock: null,
parent: null,
revision: 0,
delay: 0,
gap: 0,
@@ -28,7 +28,7 @@ const mockEvent = {
timeEnd: 1000,
duration: 1000,
skip: false,
currentBlock: null,
parent: null,
} as PlayableEvent;
const mockState = {
@@ -166,8 +166,8 @@ describe('mutation on runtimeState', () => {
// do this before the test so that it is applied
const entries = {
event1: { ...mockEvent, id: 'event1', timeStart: 0, timeEnd: 1000, duration: 1000, currentBlock: null },
event2: { ...mockEvent, id: 'event2', timeStart: 1000, timeEnd: 1500, duration: 500, currentBlock: null },
event1: { ...mockEvent, id: 'event1', timeStart: 0, timeEnd: 1000, duration: 1000, parent: null },
event2: { ...mockEvent, id: 'event2', timeStart: 1000, timeEnd: 1500, duration: 500, parent: null },
};
const rundown = makeRundown({ entries, order: ['event1', 'event2'] });
@@ -346,11 +346,11 @@ describe('loadBlock', () => {
test('from no-block to a block will clear startedAt', () => {
const rundown = makeRundown({
entries: {
0: makeOntimeEvent({ id: '0', currentBlock: null }),
0: makeOntimeEvent({ id: '0', parent: null }),
1: makeOntimeBlock({ id: '1', events: ['11'] }),
11: makeOntimeEvent({ id: '11', currentBlock: '1' }),
11: makeOntimeEvent({ id: '11', parent: '1' }),
2: makeOntimeBlock({ id: '2', events: [] }),
3: makeOntimeEvent({ id: '3', currentBlock: null }),
3: makeOntimeEvent({ id: '3', parent: null }),
},
order: ['0', '1', '2', '3'],
});
@@ -374,11 +374,11 @@ describe('loadBlock', () => {
test('from block to a different block will clear startedAt', () => {
const rundown = makeRundown({
entries: {
0: makeOntimeEvent({ id: '0', currentBlock: null }),
0: makeOntimeEvent({ id: '0', parent: null }),
1: makeOntimeBlock({ id: '1', events: ['11'] }),
11: makeOntimeEvent({ id: '11', currentBlock: '1' }),
11: makeOntimeEvent({ id: '11', parent: '1' }),
2: makeOntimeBlock({ id: '2', events: ['22'] }),
22: makeOntimeEvent({ id: '22', currentBlock: '2' }),
22: makeOntimeEvent({ id: '22', parent: '2' }),
},
order: ['0', '1', '2'],
});
@@ -402,11 +402,11 @@ describe('loadBlock', () => {
test('from block to a no-block will clear startedAt', () => {
const rundown = makeRundown({
entries: {
0: makeOntimeEvent({ id: '0', currentBlock: null }),
0: makeOntimeEvent({ id: '0', parent: null }),
1: makeOntimeBlock({ id: '1', events: ['11'] }),
11: makeOntimeEvent({ id: '11', currentBlock: '1' }),
11: makeOntimeEvent({ id: '11', parent: '1' }),
2: makeOntimeBlock({ id: '2', events: ['22'] }),
22: makeOntimeEvent({ id: '22', currentBlock: '2' }),
22: makeOntimeEvent({ id: '22', parent: '2' }),
},
order: ['0', '1', '2'],
});
@@ -431,8 +431,8 @@ describe('loadBlock', () => {
const rundown = makeRundown({
entries: {
0: makeOntimeBlock({ id: '0', events: ['1', '2'] }),
1: makeOntimeEvent({ id: '1', currentBlock: '0' }),
2: makeOntimeEvent({ id: '2', currentBlock: '0' }),
1: makeOntimeEvent({ id: '1', parent: '0' }),
2: makeOntimeEvent({ id: '2', parent: '0' }),
},
order: ['0'],
});
@@ -456,8 +456,8 @@ describe('loadBlock', () => {
test('from no-block to no-block will keep startedAt', () => {
const rundown = makeRundown({
entries: {
0: makeOntimeEvent({ id: '0', currentBlock: null }),
1: makeOntimeEvent({ id: '1', currentBlock: null }),
0: makeOntimeEvent({ id: '0', parent: null }),
1: makeOntimeEvent({ id: '1', parent: null }),
},
order: ['0', '1'],
});
+1 -1
View File
@@ -733,7 +733,7 @@ export function loadBlock(rundown: Rundown, state = runtimeState) {
return;
}
const currentBlockId = state.eventNow.currentBlock;
const currentBlockId = state.eventNow.parent;
// update time only if the block has changed
if (state.currentBlock.block?.id != currentBlockId) {
+1 -1
View File
@@ -424,7 +424,7 @@ export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<Onti
gap: originalEvent.gap, // is regenerated if timer related data is changed
// short circuit empty string
cue: makeString(patchEvent.cue ?? null, originalEvent.cue),
currentBlock: originalEvent.currentBlock,
parent: originalEvent.parent,
revision: originalEvent.revision,
timeWarning: patchEvent.timeWarning ?? originalEvent.timeWarning,
timeDanger: patchEvent.timeDanger ?? originalEvent.timeDanger,
+14 -14
View File
@@ -39,7 +39,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -68,7 +68,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -97,7 +97,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -126,7 +126,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -155,7 +155,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -200,7 +200,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -229,7 +229,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -258,7 +258,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -287,7 +287,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -316,7 +316,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -361,7 +361,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -390,7 +390,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -419,7 +419,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -448,7 +448,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
+14 -14
View File
@@ -39,7 +39,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -68,7 +68,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -97,7 +97,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -126,7 +126,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -155,7 +155,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -200,7 +200,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -229,7 +229,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -258,7 +258,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -287,7 +287,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -316,7 +316,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -361,7 +361,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -390,7 +390,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -419,7 +419,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -448,7 +448,7 @@
"isPublic": true,
"skip": false,
"colour": "",
"currentBlock": null,
"parent": null,
"revision": 0,
"delay": 0,
"dayOffset": 0,
@@ -56,7 +56,7 @@ export type OntimeEvent = OntimeBaseEvent & {
custom: EntryCustomFields;
triggers?: Trigger[];
// !==== RUNTIME METADATA ====! //
currentBlock: EntryId | null;
parent: EntryId | null;
revision: number;
delay: number; // calculated at runtime
dayOffset: number; // calculated at runtime
@@ -203,7 +203,7 @@ describe('swapEventData', () => {
duration: 1,
delay: 1,
revision: 3,
currentBlock: null,
parent: null,
} as OntimeEvent;
const eventB = {
id: '2',
@@ -213,7 +213,7 @@ describe('swapEventData', () => {
duration: 2,
delay: 2,
revision: 7,
currentBlock: 'testing',
parent: 'testing',
} as OntimeEvent;
const [newA, newB] = swapEventData(eventA, eventB);
@@ -226,7 +226,7 @@ describe('swapEventData', () => {
duration: 1,
delay: 1,
revision: 3,
currentBlock: null,
parent: null,
});
expect(newB).toMatchObject({
id: '2',
@@ -236,7 +236,7 @@ describe('swapEventData', () => {
duration: 2,
delay: 2,
revision: 7,
currentBlock: 'testing',
parent: 'testing',
});
});
});
@@ -341,9 +341,9 @@ describe('getLastEvent', () => {
entries: {
1: { id: '1', type: SupportedEvent.Event } as OntimeEvent,
block: { id: 'block', type: SupportedEvent.Block, events: ['21', '22', '23'] } as OntimeBlock,
21: { id: '21', type: SupportedEvent.Event, currentBlock: 'block' } as OntimeEvent,
22: { id: '22', type: SupportedEvent.Event, currentBlock: 'block' } as OntimeEvent,
23: { id: '23', type: SupportedEvent.Event, currentBlock: 'block' } as OntimeEvent,
21: { id: '21', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
22: { id: '22', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
23: { id: '23', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
},
order: ['1', 'block'],
};
@@ -278,7 +278,7 @@ export const swapEventData = (eventA: OntimeEvent, eventB: OntimeEvent): [newA:
timeEnd: eventA.timeEnd,
duration: eventA.duration,
linkStart: eventA.linkStart,
currentBlock: eventA.currentBlock,
parent: eventA.parent,
// keep schedule metadata
delay: eventA.delay,
gap: eventA.gap,
@@ -296,7 +296,7 @@ export const swapEventData = (eventA: OntimeEvent, eventB: OntimeEvent): [newA:
timeEnd: eventB.timeEnd,
duration: eventB.duration,
linkStart: eventB.linkStart,
currentBlock: eventB.currentBlock,
parent: eventB.parent,
// keep schedule metadata
delay: eventB.delay,
gap: eventB.gap,
@@ -365,8 +365,8 @@ export function getPreviousBlock(rundown: Pick<Rundown, 'entries' | 'order'>, cu
const currentEvent = rundown.entries[currentId];
// check if event is inside a block
if (isOntimeEvent(currentEvent) && currentEvent.currentBlock) {
return rundown.entries[currentEvent.currentBlock] as OntimeBlock;
if (isOntimeEvent(currentEvent) && currentEvent.parent) {
return rundown.entries[currentEvent.parent] as OntimeBlock;
}
let foundCurrentEvent = false;