refactor: show upcoming events

This commit is contained in:
Carlos Valente
2024-08-31 10:15:13 +02:00
committed by Carlos Valente
parent db8ed93d41
commit 980ae7a7c5
@@ -126,13 +126,12 @@ export function getUpcomingEvents(events: OntimeRundown, selectedId: MaybeString
return { now: null, next: null, followedBy: null };
}
const now = selectedId ? getEventWithId(events, selectedId) : getFirstEvent(events)?.firstEvent;
let now = selectedId ? getEventWithId(events, selectedId) : null;
if (!isOntimeEvent(now)) {
return { now: null, next: null, followedBy: null };
now = null;
}
const next = getNextEvent(events, now.id)?.nextEvent;
const next = now ? getNextEvent(events, now.id)?.nextEvent : getFirstEvent(events).firstEvent;
const followedBy = next ? getNextEvent(events, next.id)?.nextEvent : null;
// Return the titles, handling nulls appropriately