From 980ae7a7c567be9b7eb6b942e4988708bf69f49f Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Sat, 31 Aug 2024 10:15:13 +0200 Subject: [PATCH] refactor: show upcoming events --- .../client/src/features/viewers/timeline/timeline.utils.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/client/src/features/viewers/timeline/timeline.utils.ts b/apps/client/src/features/viewers/timeline/timeline.utils.ts index eeb7a728d..8157085a9 100644 --- a/apps/client/src/features/viewers/timeline/timeline.utils.ts +++ b/apps/client/src/features/viewers/timeline/timeline.utils.ts @@ -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