From 5d4b7f08575fd490e67c0a9fe7deb1fcf8406c9d Mon Sep 17 00:00:00 2001 From: Luis Galeas Date: Fri, 15 Mar 2024 12:19:15 +0000 Subject: [PATCH] Handle edge case where wifi comes on/off --- frontend/static/script.js | 3 ++- frontend/static/ui.js | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/static/script.js b/frontend/static/script.js index b52a7fb..f02d1cc 100644 --- a/frontend/static/script.js +++ b/frontend/static/script.js @@ -89,12 +89,13 @@ async function fetchEvents(url) { try { const response = await fetch(url); if (!response.ok) { - return null; + return []; } return await response.json(); } catch (error) { console.error('Error fetching events:', error); } + return []; } function viewTitle({ title, refreshing, countdown, autoRefresh, currentPage }) { diff --git a/frontend/static/ui.js b/frontend/static/ui.js index 8a5decf..d203da9 100644 --- a/frontend/static/ui.js +++ b/frontend/static/ui.js @@ -214,7 +214,11 @@ function init(root, initialState, update, view) { queue = []; msgs.forEach(msg => { - state = update(state, msg, enqueue); + try { + state = update(state, msg, enqueue); + } catch (e) { + console.error(e); + } }); draw();