diff --git a/src/lib/components/common/Paginator.svelte b/src/lib/components/common/Paginator.svelte
index 3b8497703..bccfd6f7a 100644
--- a/src/lib/components/common/Paginator.svelte
+++ b/src/lib/components/common/Paginator.svelte
@@ -31,11 +31,11 @@
}
function previous() {
- if (page) dispatch("previous", page - 1);
+ if (has_previous) dispatch("previous", (page ?? 0) - 1);
}
function next() {
- if (page) dispatch("next", page + 1);
+ if (has_next) dispatch("next", (page ?? 0) + 1);
}
function goTo(page: number) {
diff --git a/src/lib/components/processing/Process.svelte b/src/lib/components/processing/Process.svelte
index 0774af00d..e51149290 100644
--- a/src/lib/components/processing/Process.svelte
+++ b/src/lib/components/processing/Process.svelte
@@ -47,13 +47,13 @@
{/if}
{#if ["success", "failure", "cancelled"].includes(status)}
-
+
{:else if status === "queued"}
-
+
{:else if progress}
-
+
{:else}
-
+
{/if}
diff --git a/src/lib/components/viewer/LoadingToolbar.svelte b/src/lib/components/viewer/LoadingToolbar.svelte
index e32e599c3..659dbdc17 100644
--- a/src/lib/components/viewer/LoadingToolbar.svelte
+++ b/src/lib/components/viewer/LoadingToolbar.svelte
@@ -9,9 +9,9 @@
Loading PDF…
{#if progress}
-
+
{:else}
-
+
{/if}
diff --git a/src/routes/(app)/projects/+page.svelte b/src/routes/(app)/projects/+page.svelte
index e3288b75f..35f9f23b0 100644
--- a/src/routes/(app)/projects/+page.svelte
+++ b/src/routes/(app)/projects/+page.svelte
@@ -34,17 +34,17 @@
$: query = data.query;
$: projects = data.projects.results;
- $: next = data.projects.next;
- $: previous = data.projects.previous;
+ $: next = data.projects.next; // this will be an API url with a cursor
+ $: previous = data.projects.previous; // this will be an API url with a cursor
function paginate(u: Nullable) {
if (!u) return;
- u = new URL(u);
- const target = new URL($page.url);
-
- const cursor = u.searchParams.get("cursor");
- if (cursor) target.searchParams.set("cursor", cursor);
- goto(target);
+ const pageUrl = new URL(u);
+ const gotoUrl = new URL($page.url);
+ // get the cursor out of the pageUrl, pass it to the gotoUrl
+ const cursor = pageUrl.searchParams.get("cursor");
+ if (cursor) gotoUrl.searchParams.set("cursor", cursor);
+ goto(gotoUrl);
}
@@ -108,8 +108,8 @@
slot="center"
has_next={Boolean(next)}
has_previous={Boolean(previous)}
- on:next={(e) => paginate(next)}
- on:previous={(e) => paginate(previous)}
+ on:next={() => paginate(next)}
+ on:previous={() => paginate(previous)}
/>
diff --git a/src/routes/(app)/projects/+page.ts b/src/routes/(app)/projects/+page.ts
index e6c8d8c53..d9de9fe7d 100644
--- a/src/routes/(app)/projects/+page.ts
+++ b/src/routes/(app)/projects/+page.ts
@@ -1,7 +1,7 @@
-import type { ProjectResults } from "$lib/api/types";
+import type { Maybe, ProjectResults } from "$lib/api/types";
import { DEFAULT_PER_PAGE } from "@/config/config.js";
-import { getOwned, getShared, list } from "$lib/api/projects";
+import { list } from "$lib/api/projects";
type ProjectFilter = "owned" | "shared" | "public";
@@ -24,36 +24,31 @@ export async function load({ url, parent, fetch }) {
filter = "public";
}
- let projects: ProjectResults = {
+ const defaultProjects: ProjectResults = {
results: [],
next: null,
previous: null,
};
+ let data: Maybe;
let error: unknown;
if (me && filter === "owned") {
- ({ data: projects = projects, error } = await list(
- { ...params, owned_by_user: true },
- fetch,
- ));
+ ({ data, error } = await list({ ...params, owned_by_user: true }, fetch));
}
if (me && filter === "shared") {
- ({ data: projects = projects, error } = await list(
- { ...params, is_shared: true },
- fetch,
- ));
+ ({ data, error } = await list({ ...params, is_shared: true }, fetch));
}
if (filter === "public") {
- ({ data: projects = projects, error } = await list(params, fetch));
+ ({ data, error } = await list(params, fetch));
}
return {
error,
list: filter,
- projects,
+ projects: data ?? defaultProjects,
query,
cursor,
per_page,