mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-15 11:20:36 +08:00
Display seeding icon on seeded projects in node view project list
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
<script lang="ts">
|
||||
import type { BaseUrl, NodeStats, Policy, Scope } from "@httpd-client";
|
||||
import type {
|
||||
BaseUrl,
|
||||
NodeStats,
|
||||
Policy,
|
||||
ProjectListQuery,
|
||||
Scope,
|
||||
} from "@httpd-client";
|
||||
import type { ComponentProps } from "svelte";
|
||||
import type { ProjectInfo } from "@app/components/ProjectCard";
|
||||
|
||||
import * as router from "@app/lib/router";
|
||||
import { api, httpdStore } from "@app/lib/httpd";
|
||||
@@ -7,12 +15,14 @@
|
||||
import { fetchProjectInfos } from "@app/components/ProjectCard";
|
||||
import { handleError } from "@app/views/nodes/error";
|
||||
import { isDelegate } from "@app/lib/roles";
|
||||
import { onMount } from "svelte";
|
||||
|
||||
import AppLayout from "@app/App/AppLayout.svelte";
|
||||
import CopyableId from "@app/components/CopyableId.svelte";
|
||||
import ProjectCard from "@app/components/ProjectCard.svelte";
|
||||
import ErrorMessage from "@app/components/ErrorMessage.svelte";
|
||||
import Loading from "@app/components/Loading.svelte";
|
||||
import ScopePolicyPopover from "./ScopePolicyPopover.svelte";
|
||||
import ProjectCard from "@app/components/ProjectCard.svelte";
|
||||
import ScopePolicyPopover from "@app/views/nodes/ScopePolicyPopover.svelte";
|
||||
|
||||
export let baseUrl: BaseUrl;
|
||||
export let nid: string;
|
||||
@@ -22,6 +32,36 @@
|
||||
export let policy: Policy | undefined = undefined;
|
||||
export let scope: Scope | undefined = undefined;
|
||||
|
||||
let localProjects:
|
||||
| ProjectInfo[]
|
||||
| ComponentProps<ErrorMessage>["error"]
|
||||
| undefined;
|
||||
|
||||
onMount(async () => {
|
||||
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 = await fetchProjectInfos(api.baseUrl, query).catch(
|
||||
error => error,
|
||||
);
|
||||
});
|
||||
|
||||
function isSeeding(projectId: string) {
|
||||
if (localProjects instanceof Error) {
|
||||
console.error("Not able to fetch local projects", localProjects);
|
||||
return false;
|
||||
}
|
||||
return localProjects?.some(p => p.project.id === projectId) ?? false;
|
||||
}
|
||||
|
||||
$: hostname = isLocal(baseUrl.hostname) ? "Local Node" : baseUrl.hostname;
|
||||
$: session =
|
||||
$httpdStore.state === "authenticated" && isLocal(api.baseUrl.hostname)
|
||||
@@ -155,7 +195,9 @@
|
||||
{#each projectInfos as projectInfo}
|
||||
<ProjectCard
|
||||
{projectInfo}
|
||||
isSeeding={false}
|
||||
isSeeding={isLocal(baseUrl.hostname)
|
||||
? true
|
||||
: isSeeding(projectInfo.project.id)}
|
||||
isDelegate={isDelegate(
|
||||
session?.publicKey,
|
||||
projectInfo.project.delegates,
|
||||
|
||||
Reference in New Issue
Block a user