From 450c6ec6f43caa641d0fe4088a7941cd3590aa0f Mon Sep 17 00:00:00 2001 From: xaralis <filip.varecha@fragaria.cz> Date: Mon, 4 Jan 2021 10:23:02 +0100 Subject: [PATCH] fix: possible Home crash when program isn't loaded yet --- src/pages/Home.jsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index e2c5602..4864962 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -94,11 +94,24 @@ const Home = () => { ? programEntries[scheduleIds[0]] : null; - if (!programEntry && new Date() < firstProgramEntry.expectedStartAt) { - return <NotYetStarted startAt={firstProgramEntry.expectedStartAt} />; + if ( + !programEntry && + (!firstProgramEntry || new Date() < firstProgramEntry.expectedStartAt) + ) { + return ( + <NotYetStarted + startAt={ + firstProgramEntry ? firstProgramEntry.expectedStartAt : undefined + } + /> + ); } - if (!programEntry && new Date() > lastProgramEntry.expectedStartAt) { + if ( + !programEntry && + lastProgramEntry && + new Date() > lastProgramEntry.expectedStartAt + ) { return <AlreadyFinished />; } -- GitLab