refactor: add guards around trivial index checks

This commit is contained in:
Carlos Valente
2025-12-11 17:59:46 +01:00
committed by Carlos Valente
parent 242cefd35c
commit 426d42ab63
7 changed files with 35 additions and 8 deletions
@@ -213,6 +213,9 @@ function add(rundown: Rundown, entry: OntimeEntry, afterId: EntryId | null, pare
*/
function edit(rundown: Rundown, patch: PatchWithId): { entry: OntimeEntry; didInvalidate: boolean } {
const entry = rundown.entries[patch.id];
if (!entry) {
throw new Error(`Entry with id ${patch.id} not found`);
}
// apply the patch and replace the entry
const newEntry = applyPatchToEntry(entry, patch);