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

"Your Projects" list not showing all projects #925

Merged
merged 5 commits into from
Dec 3, 2024
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
4 changes: 2 additions & 2 deletions src/lib/components/common/Paginator.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/processing/Process.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
{/if}
</div>
{#if ["success", "failure", "cancelled"].includes(status)}
<progress value={1} />
<progress value={1} data-chromatic="ignore" />
{:else if status === "queued"}
<progress value={0} />
<progress value={0} data-chromatic="ignore" />
{:else if progress}
<progress value={progress} />
<progress value={progress} data-chromatic="ignore" />
{:else}
<progress />
<progress data-chromatic="ignore" />
{/if}
</div>

Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/viewer/LoadingToolbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<div class="container" slot="center">
<p>Loading PDF…</p>
{#if progress}
<progress value={progress} />
<progress value={progress} data-chromatic="ignore" />
{:else}
<progress />
<progress data-chromatic="ignore" />
{/if}
</div>
</PageToolbar>
Expand Down
20 changes: 10 additions & 10 deletions src/routes/(app)/projects/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<URL | string>) {
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);
}
</script>

Expand Down Expand Up @@ -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)}
/>
</PageToolbar>
</ContentLayout>
Expand Down
21 changes: 8 additions & 13 deletions src/routes/(app)/projects/+page.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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<ProjectResults>;
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,
Expand Down
Loading