Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch type errors where we can #361

Merged
merged 3 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/addons/progress/AddonRun.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -220,7 +220,9 @@
{#if run.message || run.file_url}
<div class="info message processingText" class:compact>
{#if run.message}{run.message}{/if}
{#if run.message && run.file_url} - {/if}
{#if run.message && run.file_url}
-
{/if}
{#if run.file_url}<a href={run.file_url}>{$_("addonProgress.download")}</a
>{/if}
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/addons/progress/AddonStatus.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions src/manager/documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/Home.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/util/visibility.js
Original file line number Diff line number Diff line change
@@ -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";
};
Expand Down
3 changes: 2 additions & 1 deletion src/viewer/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down