mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 23:19:09 +00:00
refactor: initialise data
This commit is contained in:
committed by
Carlos Valente
parent
dae32e89a3
commit
84792bc00d
@@ -11,7 +11,7 @@ import {
|
||||
} from 'ontime-types';
|
||||
import { generateId, insertAtIndex, reorderArray, swapEventData, checkIsNextDay } from 'ontime-utils';
|
||||
|
||||
import { DataProvider } from '../../classes/data-provider/DataProvider.js';
|
||||
import { getDataProvider } from '../../classes/data-provider/DataProvider.js';
|
||||
import { createPatch } from '../../utils/parser.js';
|
||||
import { getTotalDuration } from '../timerUtils.js';
|
||||
import { apply } from './delayUtils.js';
|
||||
@@ -59,8 +59,8 @@ export async function init(initialRundown: Readonly<OntimeRundown>, customFields
|
||||
persistedRundown = structuredClone(initialRundown) as OntimeRundown;
|
||||
persistedCustomFields = structuredClone(customFields);
|
||||
generate();
|
||||
await DataProvider.setRundown(persistedRundown);
|
||||
await DataProvider.setCustomFields(customFields);
|
||||
await getDataProvider().setRundown(persistedRundown);
|
||||
await getDataProvider().setCustomFields(customFields);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,8 +248,8 @@ export function mutateCache<T extends object>(mutation: MutatingFn<T>) {
|
||||
});
|
||||
|
||||
// defer writing to the database
|
||||
setImmediate(() => {
|
||||
DataProvider.setRundown(persistedRundown);
|
||||
setImmediate(async () => {
|
||||
await getDataProvider().setRundown(persistedRundown);
|
||||
});
|
||||
|
||||
return { newEvent, newRundown, didMutate };
|
||||
@@ -413,9 +413,9 @@ function invalidateIfUsed(label: CustomFieldLabel) {
|
||||
}
|
||||
// ... and schedule a cache update
|
||||
// schedule a non priority cache update
|
||||
setImmediate(() => {
|
||||
setImmediate(async () => {
|
||||
generate();
|
||||
DataProvider.setRundown(persistedRundown);
|
||||
await getDataProvider().setRundown(persistedRundown);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -424,8 +424,8 @@ function invalidateIfUsed(label: CustomFieldLabel) {
|
||||
* @param persistedCustomFields
|
||||
*/
|
||||
function scheduleCustomFieldPersist(persistedCustomFields: CustomFields) {
|
||||
setImmediate(() => {
|
||||
DataProvider.setCustomFields(persistedCustomFields);
|
||||
setImmediate(async () => {
|
||||
await getDataProvider().setCustomFields(persistedCustomFields);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user