Skip to content

Commit

Permalink
βš οΈπŸ”§ HOTFIX - Fix client side exception on home page (#3129)
Browse files Browse the repository at this point in the history
* πŸ› Fixed live steam hook attempti ng to access props when liveStream is null

* πŸ› Added fallback logic where livestream bannerwill not be displayed if it is null

---------

Co-authored-by: Calinator444 <[email protected]>
  • Loading branch information
Calinator444 and Calinator444 authored Sep 19, 2024
1 parent 65a6c86 commit dd3a5bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
12 changes: 7 additions & 5 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export default async function RootLayout({
});

const liveStreamData: EventInfoStatic =
nextUG.data.eventsCalendarConnection.edges.length > 0
? nextUG.data.eventsCalendarConnection.edges[0].node
nextUG?.data?.eventsCalendarConnection?.edges?.length > 0
? nextUG?.data?.eventsCalendarConnection?.edges[0]?.node
: null;

return (
Expand All @@ -76,9 +76,11 @@ export default async function RootLayout({
>
<header className="no-print">
<Suspense>
<LiveStream event={liveStreamData}>
<MenuWrapper menu={menuData.data.megamenu.menuGroups} />
</LiveStream>
{liveStreamData && (
<LiveStream event={liveStreamData}>
<MenuWrapper menu={menuData.data.megamenu.menuGroups} />
</LiveStream>
)}
</Suspense>
</header>
<main className="grow bg-white">{children}</main>
Expand Down
4 changes: 2 additions & 2 deletions components/layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ export const Layout = ({
)}
>
<header className="no-print">
{(showBanner || router?.query?.liveBanner?.length > 0) && (
{event && (showBanner || router?.query?.liveBanner?.length > 0) && (
<LiveStreamBanner
countdownMins={countdownMins}
liveStreamData={event}
isLive={!!isLive}
/>
)}
<div className="mx-auto max-w-9xl px-8">
{(isLive || router.query.liveStream) && (
{event && (isLive || router?.query?.liveStream) && (
<LiveStreamWidget
event={event}
countdownMins={countdownMins}
Expand Down
6 changes: 3 additions & 3 deletions hooks/useLiveStreamProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export function useLiveStreamTimer(event: EventInfo): LiveStreamProps {

useEffect(() => {
const rightnow = dayjs().utc();
const liveDelay = event.liveStreamDelayMinutes ?? 0;
if (!liveStreamDelayMinutes && event.delayedLiveStreamStart) {
const liveDelay = event?.liveStreamDelayMinutes ?? 0;
if (!liveStreamDelayMinutes && event?.delayedLiveStreamStart) {
setLiveStreamDelayMinutes(liveDelay);
}

const start = dayjs(event.startDateTime).add(liveDelay, "minute");
const start = dayjs(event?.startDateTime).add(liveDelay, "minute");
const minsToStart = start.diff(rightnow, "minute");
setCountdownMins(minsToStart);

Expand Down

0 comments on commit dd3a5bd

Please sign in to comment.