import { WindowControls } from "@/components/window-controls"; import { Button } from "@/components/ui/button"; import { Outlet, useLocation, useNavigate, useParams } from "react-router-dom"; import { Home, Settings } from "lucide-react"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { useNetworks } from "@/hooks/use-networks"; import { particlePath } from "@/lib/particle-path"; import { useParticle } from "@/hooks/use-particle"; import type { Particle } from "@/api/types"; function getParticleDisplayName(particle: Particle): string { switch (particle.type) { case "stream": case "folder": return particle.properties.name; case "quest": return particle.properties.title; case "paper": return particle.properties.title; case "file": return particle.properties.filename; case "text": return particle.properties.content.slice(0, 30); case "media": return particle.type; } } function NetworkBreadcrumbContent({ networkId }: { networkId: string }) { const { data: networks } = useNetworks(); const network = networks?.find((n) => n.id === networkId); const name = network?.name ?? networkId; const initials = name.slice(0, 2).toUpperCase(); return ( {initials} {name} ); } function TopBar() { const navigate = useNavigate(); const { networkId, "*": rest } = useParams(); const segments = [networkId, ...rest?.split("/") ?? []].filter(Boolean); const path = rest ? particlePath(networkId!, rest.split("/").filter(Boolean)) : undefined; const { data: particle } = useParticle(path); return (
{segments.length === 0 ? ( ) : ( navigate("/")} > )} {networkId && ( {segments.length === 1 ? ( ) : ( navigate(`/${networkId}`)} > )} )} {particle && ( {getParticleDisplayName(particle)} )}
); } export default function Layout() { return (
); }