import { type Accessor, createMemo, createResource, Show } from "solid-js"; import { getUserRepoByRkey } from "../../../util/get_repo"; import { figureOutHandle } from "../../../util/handle"; import type { DID } from "../../../util/types"; import { useRepoInfo } from "../context"; function HeaderItem(props: { path: string; title: string; icon: string; windowPath: Accessor; }) { return (
{props.title} ); } export function Header(props: { user: string; repo: string }) { const repoInfo = useRepoInfo(); const path = createMemo(() => { const path = window.location.pathname.split("/")[3]; return ["issues", "pulls", "pipelines"].includes(path) ? path : "overview"; }); const [forkedInfo] = createResource( () => repoInfo()?.repo, (repo) => (async () => { if (!repo.source) return; const [, , did, , rkey] = repo.source.split("/"); if (rkey === repo.rkey) return; return { did: did as DID, repo: await getUserRepoByRkey(did as DID, rkey), }; })(), ); const [forkedHandle] = createResource(forkedInfo, (forkedInfo) => (async () => await figureOutHandle(forkedInfo.did))(), ); return ( {(repoInfo) => (
{/**/}
)} ); }