mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-10 01:43:43 +00:00
chore: improve convention entry <> event
This commit is contained in:
@@ -8,13 +8,13 @@ import {
|
||||
addEvent,
|
||||
applyDelay,
|
||||
batchEditEvents,
|
||||
deleteAllEvents,
|
||||
deleteAllEntries,
|
||||
deleteEvent,
|
||||
editEvent,
|
||||
reorderEvent,
|
||||
reorderEntry,
|
||||
swapEvents,
|
||||
} from '../../services/rundown-service/RundownService.js';
|
||||
import { getEventWithId, getCurrentRundown } from '../../services/rundown-service/rundownUtils.js';
|
||||
import { getEntryWithId, getCurrentRundown } from '../../services/rundown-service/rundownUtils.js';
|
||||
|
||||
export async function rundownGetAll(_req: Request, res: Response<ProjectRundownsList>) {
|
||||
const rundown = getCurrentRundown();
|
||||
@@ -30,7 +30,7 @@ export async function rundownGetById(req: Request, res: Response<OntimeEntry | E
|
||||
const { eventId } = req.params;
|
||||
|
||||
try {
|
||||
const event = getEventWithId(eventId);
|
||||
const event = getEntryWithId(eventId);
|
||||
|
||||
if (!event) {
|
||||
res.status(404).send({ message: 'Event not found' });
|
||||
@@ -93,7 +93,7 @@ export async function rundownReorder(req: Request, res: Response<OntimeEntry | E
|
||||
|
||||
try {
|
||||
const { eventId, from, to } = req.body;
|
||||
const event = await reorderEvent(eventId, from, to);
|
||||
const event = await reorderEntry(eventId, from, to);
|
||||
res.status(200).send(event.newEvent);
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
@@ -128,7 +128,7 @@ export async function rundownApplyDelay(req: Request, res: Response<MessageRespo
|
||||
|
||||
export async function rundownDelete(_req: Request, res: Response<MessageResponse | ErrorResponse>) {
|
||||
try {
|
||||
await deleteAllEvents();
|
||||
await deleteAllEntries();
|
||||
res.status(204).send({ message: 'All events deleted' });
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
|
||||
@@ -2,7 +2,7 @@ import { EndAction, OntimeEvent, TimerType, isKeyOfType, isOntimeEvent } from 'o
|
||||
import { MILLIS_PER_SECOND, maxDuration } from 'ontime-utils';
|
||||
|
||||
import { editEvent } from '../services/rundown-service/RundownService.js';
|
||||
import { getEventWithId } from '../services/rundown-service/rundownUtils.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';
|
||||
|
||||
@@ -64,7 +64,7 @@ export function parseProperty(property: string, value: unknown) {
|
||||
* @param {Partial<OntimeEvent>} patchEvent
|
||||
*/
|
||||
export function updateEvent(patchEvent: Partial<OntimeEvent> & { id: string }) {
|
||||
const event = getEventWithId(patchEvent?.id ?? '');
|
||||
const event = getEntryWithId(patchEvent?.id ?? '');
|
||||
if (!event) {
|
||||
throw new Error(`Event with ID ${patchEvent?.id} not found`);
|
||||
}
|
||||
|
||||
@@ -126,9 +126,9 @@ export async function deleteEvent(eventIds: string[]) {
|
||||
}
|
||||
|
||||
/**
|
||||
* deletes all events in database
|
||||
* deletes all entries in database
|
||||
*/
|
||||
export async function deleteAllEvents() {
|
||||
export async function deleteAllEntries() {
|
||||
const scopedMutation = cache.mutateCache(cache.removeAll);
|
||||
await scopedMutation({});
|
||||
|
||||
@@ -182,12 +182,12 @@ export async function batchEditEvents(ids: string[], data: Partial<OntimeEvent>)
|
||||
}
|
||||
|
||||
/**
|
||||
* reorders a given event
|
||||
* reorders a given entry
|
||||
* @param {string} eventId - ID of event from, for sanity check
|
||||
* @param {number} from - index of event from
|
||||
* @param {number} to - index of event to
|
||||
*/
|
||||
export async function reorderEvent(eventId: string, from: number, to: number) {
|
||||
export async function reorderEntry(eventId: EntryId, from: number, to: number) {
|
||||
const scopedMutation = cache.mutateCache(cache.reorder);
|
||||
const reorderedItem = await scopedMutation({ eventId, from, to });
|
||||
|
||||
|
||||
@@ -60,9 +60,9 @@ export function getEventAtIndex(eventIndex: number): OntimeEvent | undefined {
|
||||
/**
|
||||
* returns first event that matches a given ID
|
||||
*/
|
||||
export function getEventWithId(eventId: string): OntimeEntry | undefined {
|
||||
export function getEntryWithId(entryId: EntryId): OntimeEntry | undefined {
|
||||
const { entries } = getCurrentRundown();
|
||||
return entries[eventId];
|
||||
return entries[entryId];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ export function getEventWithId(eventId: string): OntimeEntry | undefined {
|
||||
export function getFirstPlayable(playableOrder: EntryId[]): PlayableEvent | undefined {
|
||||
const firstEventId = playableOrder.at(0);
|
||||
if (!firstEventId) return;
|
||||
return getEventWithId(firstEventId) as PlayableEvent | undefined;
|
||||
return getEntryWithId(firstEventId) as PlayableEvent | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ export function getNextEventWithCue(targetCue: string, currentEventIndex = 0): O
|
||||
|
||||
for (let i = currentEventIndex; i < playableEventsOrder.length; i++) {
|
||||
const eventId = playableEventsOrder[i];
|
||||
const event = getEventWithId(eventId) as PlayableEvent | undefined;
|
||||
const event = getEntryWithId(eventId) as PlayableEvent | undefined;
|
||||
if (event?.cue.toLowerCase() === lowerCaseCue) {
|
||||
return event;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ export function findPrevious(currentEventId?: string): OntimeEvent | undefined {
|
||||
return getFirstPlayable(playableEventsOrder);
|
||||
}
|
||||
|
||||
return getEventWithId(previousEventId) as PlayableEvent | undefined;
|
||||
return getEntryWithId(previousEventId) as PlayableEvent | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ export function findNext(currentEventId?: string): PlayableEvent | undefined {
|
||||
return getFirstPlayable(playableEventsOrder);
|
||||
}
|
||||
|
||||
return getEventWithId(nextEventId) as PlayableEvent | undefined;
|
||||
return getEntryWithId(nextEventId) as PlayableEvent | undefined;
|
||||
}
|
||||
|
||||
export function filterTimedEvents(rundown: Rundown, timedEventOrder: EntryId[]): OntimeEvent[] {
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
findPrevious,
|
||||
getEventAtIndex,
|
||||
getNextEventWithCue,
|
||||
getEventWithId,
|
||||
getEntryWithId,
|
||||
getCurrentRundown,
|
||||
getTimedEvents,
|
||||
getRundownData,
|
||||
@@ -258,7 +258,7 @@ class RuntimeService {
|
||||
if (safeOption || eventInMemory) {
|
||||
if (state.eventNow !== null) {
|
||||
// load stuff again, but keep running if our events still exist
|
||||
const eventNow = getEventWithId(state.eventNow.id);
|
||||
const eventNow = getEntryWithId(state.eventNow.id);
|
||||
if (!isOntimeEvent(eventNow) || !isPlayableEvent(eventNow)) {
|
||||
// maybe the event was deleted or the skip state was changed
|
||||
runtimeState.stop();
|
||||
@@ -323,7 +323,7 @@ class RuntimeService {
|
||||
*/
|
||||
@broadcastResult
|
||||
public startById(eventId: string): boolean {
|
||||
const event = getEventWithId(eventId);
|
||||
const event = getEntryWithId(eventId);
|
||||
if (!event || !isOntimeEvent(event)) {
|
||||
return false;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ class RuntimeService {
|
||||
*/
|
||||
@broadcastResult
|
||||
public loadById(eventId: string): boolean {
|
||||
const event = getEventWithId(eventId);
|
||||
const event = getEntryWithId(eventId);
|
||||
if (!event || !isOntimeEvent(event)) {
|
||||
return false;
|
||||
}
|
||||
@@ -654,7 +654,7 @@ class RuntimeService {
|
||||
|
||||
// the db would have to change for the event not to exist
|
||||
// we do not know the reason for the crash, so we check anyway
|
||||
const event = getEventWithId(selectedEventId);
|
||||
const event = getEntryWithId(selectedEventId);
|
||||
if (!isOntimeEvent(event) || !isPlayableEvent(event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user