Skip to content

Commit

Permalink
Fix more embed types. Ignore TS errors on code we're not keeping.
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Apr 16, 2024
1 parent 45ccbfb commit ededd32
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/api/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class SessionCache {

const sessionCache = new SessionCache();

// @ts-ignore
session.getStatic = async function getStatic(url) {
if (sessionCache.has(url)) {
return sessionCache.lookup(url);
Expand Down
1 change: 1 addition & 0 deletions src/api/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export function documentDimensionUrl(document) {
function getDesiredSize(desiredWidth) {
for (let i = 0; i < IMAGE_WIDTHS.length; i++) {
const [width, name] = IMAGE_WIDTHS[i];
// @ts-ignore
if (desiredWidth <= width) return name;
}
return IMAGE_WIDTHS[IMAGE_WIDTHS.length - 1][1];
Expand Down
10 changes: 6 additions & 4 deletions src/lib/api/addons.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Page } from "@/api/types/common";
import type { AddOnListItem } from "@/addons/types";

import { error } from "@sveltejs/kit";

import { BASE_API_URL } from "@/config/config.js";
import { type AddOnListItem } from "@/addons/types";
import { isErrorCode } from "../utils";
import type { Page } from "@/api/types/common";

export async function getPinnedAddons(
fetch = globalThis.fetch,
Expand All @@ -15,7 +17,7 @@ export async function getPinnedAddons(
if (isErrorCode(resp.status)) {
error(resp.status, resp.statusText);
}
return resp.json();
return resp.json() as Promise<Page<AddOnListItem>>;
}

export async function getAddons(
Expand All @@ -26,5 +28,5 @@ export async function getAddons(
if (isErrorCode(resp.status)) {
error(resp.status, resp.statusText);
}
return resp.json();
return resp.json() as Promise<Page<AddOnListItem>>;
}
5 changes: 4 additions & 1 deletion src/routes/(embed)/documents/[id]/pages/[page]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { _ } from "svelte-i18n";
import Annotation from "./Annotation.svelte";
Expand All @@ -18,6 +19,8 @@
export let data;
const dispatch = createEventDispatcher();
let elem;
let active = null;
Expand Down
15 changes: 8 additions & 7 deletions src/routes/(embed)/projects/[project_id]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
<script lang="ts">
import type { Document } from "$lib/api/types";
import DocumentListItem from "$lib/components/documents/DocumentListItem.svelte";
import Paginator from "$lib/components/common/Paginator.svelte";
Expand All @@ -11,17 +12,17 @@
$: count = data.documents.count;
$: next = data.documents.next;
$: previous = data.documents.previous;
$: documents = data.documents.results.map((d) => d.document);
$: documents = data.documents.results.map((d) => d.document) as Document[];
$: total_pages = Math.ceil(count / per_page);
async function load(url) {
const res = await fetch(url, { credentials: "include" }).catch((e) => ({
ok: false,
error: e,
}));
const res = await fetch(url, { credentials: "include" }).catch((e) => {
console.error(e);
return { ok: false, json: () => {} };
});
if (!res.ok) {
console.error(res.error);
return;
}
data.documents = await res.json();
Expand Down
6 changes: 4 additions & 2 deletions src/routes/app/sidebar/AddOns.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts">
import type { Page } from "@/api/types/common";
import type { AddOnListItem } from "@/addons/types";
import { Book16, Hourglass24, Pin24, Plug16 } from "svelte-octicons";
import type { Page } from "@/api/types";
import type { AddOnListItem } from "$lib/api/types";
import Action from "$lib/components/common/Action.svelte";
import Empty from "$lib/components/common/Empty.svelte";
import Flex from "$lib/components/common/Flex.svelte";
Expand Down

0 comments on commit ededd32

Please sign in to comment.