Radish alpha
r
rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5
Radicle web interface
Radicle
Git
Query all local repos by getting the local repo count
Merged did:key:z6MkkfM3...sVz5 opened 2 years ago

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.

check check-visual check-unit-test check-httpd-api-unit-test check-e2e check-build

👉 Preview
👉 Workflow runs
👉 Branch on GitHub

5 files changed +30 -10 493d33a8 67eef6ca
modified 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,
modified 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<Project[]> {
    return this.#fetcher.fetchOk(
modified 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<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([
modified src/views/home/Index.svelte
@@ -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) {
modified src/views/nodes/View.svelte
@@ -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">