From 67eef6caa7181f74cb5facca483dfc6cd9240590 Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Wed, 13 Mar 2024 15:13:52 +0100 Subject: [PATCH] Query all local repos by getting the local repo count Instead of falling back to the default of 10 repos, set by radicle-httpd. We query the local httpd instance for the amount of repos hosted. --- httpd-client/index.ts | 4 +++- httpd-client/lib/project.ts | 7 ++++++- src/components/ProjectCard.ts | 6 ++++-- src/views/home/Index.svelte | 21 ++++++++++++++++----- src/views/nodes/View.svelte | 2 +- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/httpd-client/index.ts b/httpd-client/index.ts index 5637d5cd4..449f17e6c 100644 --- a/httpd-client/index.ts +++ b/httpd-client/index.ts @@ -1,10 +1,11 @@ import type { BaseUrl } from "./lib/fetcher.js"; import type { Blob, + DiffResponse, Project, + ProjectListQuery, Remote, Tree, - DiffResponse, } from "./lib/project.js"; import type { SuccessResponse, @@ -70,6 +71,7 @@ export type { PatchUpdateAction, Policy, Project, + ProjectListQuery, Range, Reaction, Remote, diff --git a/httpd-client/lib/project.ts b/httpd-client/lib/project.ts index 2628e58f2..d11706d30 100644 --- a/httpd-client/lib/project.ts +++ b/httpd-client/lib/project.ts @@ -141,6 +141,11 @@ const diffResponseSchema = object({ files: record(string(), diffBlobSchema), }); +export type ProjectListQuery = { + page?: number; + perPage?: number; + show?: "pinned" | "all"; +}; export class Client { #fetcher: Fetcher; @@ -181,7 +186,7 @@ export class Client { } public async getAll( - query?: { page?: number; perPage?: number; show?: "pinned" | "all" }, + query?: ProjectListQuery, options?: RequestOptions, ): Promise { return this.#fetcher.fetchOk( diff --git a/src/components/ProjectCard.ts b/src/components/ProjectCard.ts index cea32b018..813ad7dd1 100644 --- a/src/components/ProjectCard.ts +++ b/src/components/ProjectCard.ts @@ -1,3 +1,5 @@ +import type { ProjectListQuery } from "@httpd-client"; + import { loadProjectActivity, type WeeklyActivity } from "@app/lib/commit"; import { HttpdClient, @@ -15,10 +17,10 @@ export interface ProjectInfo { export async function fetchProjectInfos( baseUrl: BaseUrl, - show: "all" | "pinned", + query?: ProjectListQuery, ): Promise { const api = new HttpdClient(baseUrl); - const projects = await api.project.getAll({ show }); + const projects = await api.project.getAll(query); const info = await Promise.all( projects.map(async project => { const [activity, lastCommit] = await Promise.all([ diff --git a/src/views/home/Index.svelte b/src/views/home/Index.svelte index fe9e8f689..e5a405ec5 100644 --- a/src/views/home/Index.svelte +++ b/src/views/home/Index.svelte @@ -1,5 +1,6 @@