From 80d9409ed510950e64d3254f23c7ac4d851071c7 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 5 Dec 2023 10:27:33 -0500 Subject: [PATCH 1/3] Handle an undefined --- src/manager/documents.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/manager/documents.js b/src/manager/documents.js index f00063638..14b7c86f9 100644 --- a/src/manager/documents.js +++ b/src/manager/documents.js @@ -99,6 +99,7 @@ export const documents = new Svue({ return allDocuments; }, pendingExisting(docsById, pending) { + if (!pending) return []; return pending.filter((x) => { const id = x.doc_id; return docsById[id] != null; From 7c71dacef17f8269932237390ebca75e3f27803d Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 5 Dec 2023 10:41:44 -0500 Subject: [PATCH 2/3] Better error messaging --- src/addons/progress/AddonRun.svelte | 6 ++++-- src/addons/progress/AddonStatus.svelte | 5 ++++- src/pages/home/Home.svelte | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/addons/progress/AddonRun.svelte b/src/addons/progress/AddonRun.svelte index a0e5e9af6..ed9477c6d 100644 --- a/src/addons/progress/AddonRun.svelte +++ b/src/addons/progress/AddonRun.svelte @@ -57,7 +57,7 @@ const resp = await fetch(endpoint, options); if (!resp.ok) { - throw new Error(resp.statusText); + throw new Error(`Error updating add-on run: ${resp.statusText}`); } // delete returns an empty response @@ -220,7 +220,9 @@ {#if run.message || run.file_url}
{#if run.message}{run.message}{/if} - {#if run.message && run.file_url} - {/if} + {#if run.message && run.file_url} + - + {/if} {#if run.file_url}{$_("addonProgress.download")}{/if}
diff --git a/src/addons/progress/AddonStatus.svelte b/src/addons/progress/AddonStatus.svelte index 880980689..56e2659f0 100644 --- a/src/addons/progress/AddonStatus.svelte +++ b/src/addons/progress/AddonStatus.svelte @@ -22,7 +22,10 @@ const resp = await fetch(endpoint, options); if (!resp.ok) { - throw new Error(resp.statusText); + // just bail on errors and try again next cycle + return console.error( + `Failed to load add-on run status: ${resp.statusText}`, + ); } const { results } = await resp.json(); diff --git a/src/pages/home/Home.svelte b/src/pages/home/Home.svelte index a1beb5265..23363c065 100644 --- a/src/pages/home/Home.svelte +++ b/src/pages/home/Home.svelte @@ -30,7 +30,7 @@ const resp = await fetch(endpoint); if (!resp.ok) { - throw new Error(resp.statusText); + throw new Error(`Error fetching flat page: ${resp.statusText}`); } return resp.json(); From 5d55de844b30146b2267b46d516d9d81a9bd3854 Mon Sep 17 00:00:00 2001 From: Chris Amico Date: Tue, 5 Dec 2023 10:58:06 -0500 Subject: [PATCH 3/3] Catch more undefined things --- src/util/visibility.js | 3 +++ src/viewer/document.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/visibility.js b/src/util/visibility.js index 58e5ff9d1..c3a19b0e8 100644 --- a/src/util/visibility.js +++ b/src/util/visibility.js @@ -1,6 +1,9 @@ // Adapted from https://svelte.dev/repl/ead0f1fcd2d4402bbbd64eca1d665341?version=3.14.1 export function showIfFullyVisible(el) { + // for very old browsers we don't support, bail + if (typeof window.IntersectionObserver === "undefined") return; + const setVisible = (visibility) => { el.style.visibility = visibility ? "visible" : "hidden"; }; diff --git a/src/viewer/document.js b/src/viewer/document.js index 2a4543cf9..b2a569966 100644 --- a/src/viewer/document.js +++ b/src/viewer/document.js @@ -227,7 +227,8 @@ class Doc extends Svue { if (this.scrollzoom == null) return resolve(); const scrollTop = - (this.scrollzoom.components[pageNumber].y - this.layout.pageGap / 4) * + (this.scrollzoom.components[pageNumber]?.y - + this.layout.pageGap / 4) * this.scrollzoom.transform.matrix[0]; if (this.scrollzoom.element != null) { this.scrollzoom.scrollTo(scrollTop);