mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-03 10:40:30 +08:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<Project[]> {
|
||||
return this.#fetcher.fetchOk(
|
||||
|
||||
@@ -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<ProjectInfo[]> {
|
||||
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([
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { ComponentProps } from "svelte";
|
||||
import type { ProjectListQuery } from "@httpd-client";
|
||||
|
||||
import storedWritable from "@efstajas/svelte-stored-writable";
|
||||
import { derived } from "svelte/store";
|
||||
@@ -50,8 +51,19 @@
|
||||
| undefined;
|
||||
|
||||
async function loadLocalProjects() {
|
||||
const query: ProjectListQuery = { show: "all" };
|
||||
await api
|
||||
.getStats()
|
||||
.then(({ repos: { total } }) => (query.perPage = total))
|
||||
.catch(e => {
|
||||
console.error(
|
||||
"Not able to query to total repo count for your local node.",
|
||||
e,
|
||||
);
|
||||
});
|
||||
|
||||
localProjects = undefined;
|
||||
localProjects = await fetchProjectInfos(api.baseUrl, "all").catch(
|
||||
localProjects = await fetchProjectInfos(api.baseUrl, query).catch(
|
||||
error => error,
|
||||
);
|
||||
}
|
||||
@@ -60,10 +72,9 @@
|
||||
preferredSeedProjects = undefined;
|
||||
|
||||
if (!$selectedSeed) return;
|
||||
preferredSeedProjects = await fetchProjectInfos(
|
||||
$selectedSeed,
|
||||
"pinned",
|
||||
).catch(error => error);
|
||||
preferredSeedProjects = await fetchProjectInfos($selectedSeed, {
|
||||
show: "pinned",
|
||||
}).catch(error => error);
|
||||
}
|
||||
|
||||
function isSeeding(projectId: string) {
|
||||
|
||||
@@ -148,7 +148,7 @@
|
||||
</div>
|
||||
|
||||
<div style:margin-top="1rem">
|
||||
{#await fetchProjectInfos(baseUrl, isLocal(baseUrl.hostname) ? "all" : "pinned")}
|
||||
{#await fetchProjectInfos( baseUrl, { show: isLocal(baseUrl.hostname) ? "all" : "pinned" }, )}
|
||||
<Loading small center />
|
||||
{:then projectInfos}
|
||||
<div class="project-grid">
|
||||
|
||||
Reference in New Issue
Block a user