From c99ad19bba2a75b9a43e187c4f227bc18c97b50e Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 3 Nov 2023 15:08:29 -0400 Subject: [PATCH] ipad: Add timeout message for loading events image --- src/ipad.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ipad.ts b/src/ipad.ts index 8d35c9e..26db887 100644 --- a/src/ipad.ts +++ b/src/ipad.ts @@ -23,8 +23,10 @@ document.body.addEventListener('touchmove', (e) => e.preventDefault(), { const calendarImg = document.getElementById('calendar')! as HTMLImageElement; const spinner = document.getElementById('loadingSpinner')!; const errorModal = document.getElementById('errorModal')!; +let loadTimeoutId = -1; calendarImg.addEventListener('load', () => { + clearTimeout(loadTimeoutId); spinner.style.display = 'none'; errorModal.style.display = 'none'; }); @@ -53,6 +55,14 @@ function refresh() { calendarImg.src = url.toString(); calendarImg.width = window.innerWidth; calendarImg.height = window.innerHeight; + + loadTimeoutId = window.setTimeout(() => { + spinner.style.display = 'none'; + errorModal.style.display = ''; + const message = errorModal.querySelector('.modal-message')!; + message.textContent = + 'Timed out loading events. Displayed events may not be accurate.'; + }, 11000); } window.addEventListener('load', () => refresh());