Skip to content

Commit

Permalink
Fix what github broke
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 30, 2024
1 parent 63e3705 commit d450e6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 8 additions & 6 deletions src/lib/api/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,31 @@ export async function text(
// for errors
const empty = { updated: 0, pages: [] };
let url = jsonUrl(document);
// for public documents, we can just fetch the asset

// for public documents, we can just fetch the asset
// for private and organization docs, we need to hit the API first
// with credentials, and then fetch the returned location
if (document.access !== "public") {
const resp: Response | void = await fetch(url, {
credentials: "include",
redirect: "error",
headers: {
headers: {
Accept: "application/json",
},
}).catch(console.error);
if (!resp || isErrorCode(resp.status) {

if (!resp || isErrorCode(resp.status)) {
return empty;
}
}

const { location } = await resp.json();
if (!location) {
return empty;
}
url = location;
}

const resp = await fetch(location).catch(console.error);
const resp = await fetch(url).catch(console.error);
if (!resp || isErrorCode(resp.status)) {
return empty;
}
Expand Down
2 changes: 0 additions & 2 deletions src/routes/documents/[id]-[slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import { goto } from "$app/navigation";
import { page } from "$app/stores";
import { ThreeBars16 } from "svelte-octicons";
// icons
import DocumentIcon from "@/common/icons/Document.svelte";
import NotesIcon from "@/common/icons/Notes.svelte";
Expand Down

0 comments on commit d450e6a

Please sign in to comment.