chore: improve convention entry <> event

This commit is contained in:
Carlos Valente
2025-04-13 20:46:47 +02:00
committed by arc-alex
parent d2c7b34142
commit 82dc1bc56b
23 changed files with 211 additions and 210 deletions
@@ -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;
}