Skip to content

Commit

Permalink
Merge pull request #361 from MuckRock/360-typeerrors
Browse files Browse the repository at this point in the history
Catch type errors where we can
  • Loading branch information
eyeseast authored Dec 5, 2023
2 parents ba95d2d + 5d55de8 commit 885c72e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
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

0 comments on commit 885c72e

Please sign in to comment.