refactor: remove trivially inferred numEvents

This commit is contained in:
Carlos Valente
2025-05-19 22:09:28 +02:00
committed by Carlos Valente
parent 2f13d6c89e
commit 4ab9c81cb8
11 changed files with 5 additions and 20 deletions
@@ -792,7 +792,6 @@ function optimisticDeleteEntries(entryIds: EntryId[], rundown: Rundown) {
} else { } else {
const parent = entries[entry.parent] as OntimeBlock; const parent = entries[entry.parent] as OntimeBlock;
parent.events = parent.events.filter((event) => event !== entry.id); parent.events = parent.events.filter((event) => event !== entry.id);
parent.numEvents -= 1;
} }
delete entries[entry.id]; delete entries[entry.id];
@@ -134,7 +134,7 @@ export default function BlockBlock(props: BlockBlockProps) {
</div> </div>
<div className={style.metaEntry}> <div className={style.metaEntry}>
<div>Events</div> <div>Events</div>
<div>{data.numEvents}</div> <div>{data.events.length}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -90,7 +90,6 @@ export function createBlock(patch?: Partial<OntimeBlock>): OntimeBlock {
endTime: null, endTime: null,
duration: 0, duration: 0,
isFirstLinked: false, isFirstLinked: false,
numEvents: patch.events?.length ?? 0,
}; };
} }
-3
View File
@@ -52,7 +52,6 @@ export const demoDb: DatabaseModel = {
endTime: null, endTime: null,
duration: 0, duration: 0,
isFirstLinked: false, isFirstLinked: false,
numEvents: 0,
custom: { custom: {
song: 'Sekret', song: 'Sekret',
artist: 'Ronela Hajati', artist: 'Ronela Hajati',
@@ -219,7 +218,6 @@ export const demoDb: DatabaseModel = {
endTime: null, endTime: null,
duration: 0, duration: 0,
isFirstLinked: false, isFirstLinked: false,
numEvents: 0,
}, },
'1c420': { '1c420': {
type: SupportedEntry.Event, type: SupportedEntry.Event,
@@ -382,7 +380,6 @@ export const demoDb: DatabaseModel = {
endTime: null, endTime: null,
duration: 0, duration: 0,
isFirstLinked: false, isFirstLinked: false,
numEvents: 0,
}, },
'503c4': { '503c4': {
type: SupportedEntry.Event, type: SupportedEntry.Event,
@@ -54,5 +54,4 @@ export const block: Omit<OntimeBlock, 'id'> = {
endTime: null, // calculated at runtime endTime: null, // calculated at runtime
duration: 0, // calculated at runtime duration: 0, // calculated at runtime
isFirstLinked: false, // calculated at runtime isFirstLinked: false, // calculated at runtime
numEvents: 0, // calculated at runtime
}; };
@@ -550,7 +550,6 @@ describe('generate() v4', () => {
endTime: 400, endTime: 400,
duration: 300, duration: 300,
isFirstLinked: false, isFirstLinked: false,
numEvents: 3,
}, },
'100': { type: SupportedEntry.Event, parent: '1' }, '100': { type: SupportedEntry.Event, parent: '1' },
'200': { type: SupportedEntry.Event, parent: '1' }, '200': { type: SupportedEntry.Event, parent: '1' },
@@ -591,7 +590,6 @@ describe('generate() v4', () => {
endTime: 400, endTime: 400,
duration: 300, duration: 300,
isFirstLinked: false, isFirstLinked: false,
numEvents: 3,
}, },
'101': { parent: '1', gap: 90, linkStart: false }, '101': { parent: '1', gap: 90, linkStart: false },
'102': { parent: '1' }, '102': { parent: '1' },
@@ -603,7 +601,6 @@ describe('generate() v4', () => {
endTime: 800, endTime: 800,
duration: 300, duration: 300,
isFirstLinked: false, isFirstLinked: false,
numEvents: 3,
}, },
'201': { id: '201', timeStart: 500, timeEnd: 600, duration: 100, gap: 100, linkStart: false }, '201': { id: '201', timeStart: 500, timeEnd: 600, duration: 100, gap: 100, linkStart: false },
'202': { id: '202', timeStart: 600, timeEnd: 700, duration: 100 }, '202': { id: '202', timeStart: 600, timeEnd: 700, duration: 100 },
@@ -615,7 +612,6 @@ describe('generate() v4', () => {
endTime: 1200, endTime: 1200,
duration: 300, duration: 300,
isFirstLinked: false, isFirstLinked: false,
numEvents: 3,
}, },
'301': { id: '301', timeStart: 900, timeEnd: 1000, duration: 100, gap: 100, linkStart: false }, '301': { id: '301', timeStart: 900, timeEnd: 1000, duration: 100, gap: 100, linkStart: false },
'302': { id: '302', timeStart: 1000, timeEnd: 1100, duration: 100 }, '302': { id: '302', timeStart: 1000, timeEnd: 1100, duration: 100 },
@@ -169,7 +169,6 @@ export function generate(
processedEntry.endTime = blockEndTime; processedEntry.endTime = blockEndTime;
processedEntry.isFirstLinked = isFirstLinked; processedEntry.isFirstLinked = isFirstLinked;
processedEntry.events = blockEvents; processedEntry.events = blockEvents;
processedEntry.numEvents = blockEvents.length;
} }
} }
@@ -416,7 +415,6 @@ export function remove({ rundown, eventIds }: RemoveArgs): MutatingReturn {
eventId: entry.parent, eventId: entry.parent,
patch: { patch: {
events: parentEvents, events: parentEvents,
numEvents: parentEvents.length,
}, },
}); });
} }
+1
View File
@@ -1,3 +1,4 @@
/** /**
* This CSS file allows user customisation of the UI * This CSS file allows user customisation of the UI
* We expose some CSS properties to facilitate this (see below in :root) * We expose some CSS properties to facilitate this (see below in :root)
+1 -2
View File
@@ -180,8 +180,7 @@
"startTime": null, "startTime": null,
"endTime": null, "endTime": null,
"duration": 0, "duration": 0,
"isFirstLinked": false, "isFirstLinked": false
"numEvents": 0
}, },
"1c420": { "1c420": {
"type": "event", "type": "event",
+2 -4
View File
@@ -180,8 +180,7 @@
"startTime": null, "startTime": null,
"endTime": null, "endTime": null,
"duration": 0, "duration": 0,
"isFirstLinked": false, "isFirstLinked": false
"numEvents": 0
}, },
"1c420": { "1c420": {
"type": "event", "type": "event",
@@ -341,8 +340,7 @@
"startTime": null, "startTime": null,
"endTime": null, "endTime": null,
"duration": 0, "duration": 0,
"isFirstLinked": false, "isFirstLinked": false
"numEvents": 0
}, },
"503c4": { "503c4": {
"type": "event", "type": "event",
@@ -33,7 +33,6 @@ export type OntimeBlock = OntimeBaseEvent & {
endTime: MaybeNumber; // calculated at runtime endTime: MaybeNumber; // calculated at runtime
duration: number; // calculated at runtime duration: number; // calculated at runtime
isFirstLinked: boolean; // calculated at runtime, whether the first event is linked isFirstLinked: boolean; // calculated at runtime, whether the first event is linked
numEvents: number; // calculated at runtime
}; };
export type OntimeEvent = OntimeBaseEvent & { export type OntimeEvent = OntimeBaseEvent & {