refactor: extract rundown switching to a single function in rundown.service (#1930)

This commit is contained in:
Alex Christoffer Rasmussen
2026-01-05 20:47:04 +01:00
committed by GitHub
parent 680273770c
commit 6436e3fda8
2 changed files with 18 additions and 13 deletions
@@ -27,12 +27,14 @@ import { logger } from '../../classes/Logger.js';
import {
createTransaction,
customFieldMutation,
getCurrentRundown,
rundownCache,
rundownMutation,
updateBackgroundRundown,
} from './rundown.dao.js';
import type { RundownMetadata } from './rundown.types.js';
import { generateEvent, getInsertAfterId, hasChanges } from './rundown.utils.js';
import { getDataProvider } from '../../classes/data-provider/DataProvider.js';
/**
* creates a new entry with given data
@@ -596,6 +598,20 @@ function notifyChanges(rundownMetadata: RundownMetadata, revision: number, optio
}
}
/**
* @throws if the provided id does not exist
*/
export async function loadRundown(id: string) {
const dataProvider = getDataProvider();
if (id === getCurrentRundown().id) {
return dataProvider.getProjectRundowns();
}
const rundown = dataProvider.getRundown(id);
const customField = dataProvider.getCustomFields();
await initRundown(rundown, customField);
return dataProvider.getProjectRundowns();
}
/**
* Sets a new rundown in the cache
* and marks it as the currently loaded one