mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-13 03:13:47 +00:00
refactor: create transaction system and apply to adding entry (#1620)
* refactor: create transaction system and apply to adding entry * refactor: migrate edit mutations to transaction * refactor: migrate delete mutation to transaction * refactor: migrate reorder mutation to transaction * refactor: migrate apply delay to transaction * refactor: migrate swapEvents to transaction * refactor: migrate clone to transaction * refactor: migrate group/ungroup transactions * refactor: simplify mutations * refactor: migrate getters * chore: add tests to processRundown()
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { EndAction, OntimeEvent, TimerType, isKeyOfType, isOntimeEvent } from 'ontime-types';
|
||||
import { EndAction, TimerType, isKeyOfType } from 'ontime-types';
|
||||
import { MILLIS_PER_SECOND, maxDuration } from 'ontime-utils';
|
||||
|
||||
import { editEvent } from '../services/rundown-service/RundownService.js';
|
||||
import { getEntryWithId } from '../services/rundown-service/rundownUtils.js';
|
||||
import { coerceBoolean, coerceColour, coerceEnum, coerceNumber, coerceString } from '../utils/coerceType.js';
|
||||
import { getDataProvider } from '../classes/data-provider/DataProvider.js';
|
||||
|
||||
@@ -58,19 +56,3 @@ export function parseProperty(property: string, value: unknown) {
|
||||
const parserFn = propertyConversion[property];
|
||||
return { [property]: parserFn(value) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a property of the event with the given id
|
||||
* @param {Partial<OntimeEvent>} patchEvent
|
||||
*/
|
||||
export function updateEvent(patchEvent: Partial<OntimeEvent> & { id: string }) {
|
||||
const event = getEntryWithId(patchEvent?.id ?? '');
|
||||
if (!event) {
|
||||
throw new Error(`Event with ID ${patchEvent?.id} not found`);
|
||||
}
|
||||
|
||||
if (!isOntimeEvent(event)) {
|
||||
throw new Error('Can only update events');
|
||||
}
|
||||
editEvent(patchEvent);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user