ipad: Add timeout message for loading events image

This commit is contained in:
Adam Goldsmith 2023-11-03 15:08:29 -04:00
parent d040edf6a0
commit c99ad19bba

View File

@ -23,8 +23,10 @@ document.body.addEventListener('touchmove', (e) => e.preventDefault(), {
const calendarImg = document.getElementById('calendar')! as HTMLImageElement; const calendarImg = document.getElementById('calendar')! as HTMLImageElement;
const spinner = document.getElementById('loadingSpinner')!; const spinner = document.getElementById('loadingSpinner')!;
const errorModal = document.getElementById('errorModal')!; const errorModal = document.getElementById('errorModal')!;
let loadTimeoutId = -1;
calendarImg.addEventListener('load', () => { calendarImg.addEventListener('load', () => {
clearTimeout(loadTimeoutId);
spinner.style.display = 'none'; spinner.style.display = 'none';
errorModal.style.display = 'none'; errorModal.style.display = 'none';
}); });
@ -53,6 +55,14 @@ function refresh() {
calendarImg.src = url.toString(); calendarImg.src = url.toString();
calendarImg.width = window.innerWidth; calendarImg.width = window.innerWidth;
calendarImg.height = window.innerHeight; 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()); window.addEventListener('load', () => refresh());