import { useParams } from "react-router-dom"; import { useLiveParticle } from "@/hooks/use-particle"; import { particlePath } from "@/lib/particle-path"; import { isContainerType } from "@/api/types"; import { StreamView } from "@/features/particles/stream-view"; import { FolderView } from "@/features/particles/folder-view"; import { ParticleListView } from "@/features/particles/particle-list-view"; /** * Route-level component for /:networkId/*. * Reads params from the router, resolves the particle, and renders * the appropriate view based on particle type. */ export default function ParticleViewResolver() { const { networkId, "*": rest } = useParams(); const segments = (rest ?? "").split("/").filter(Boolean); const path = particlePath(networkId!, segments); // path of current container particle const { particle, isLoading, error } = useLiveParticle(path); if (isLoading) { return (

Loading...

); } if (error) { return (

Failed to load particle

); } if (!particle) { return (

Particle: {segments.join(" / ")}

); } switch (particle.type) { case "stream": return ; case "folder": return ; default: if (isContainerType(particle.type)) { return ; } return (

{particle.type} particle: {particle.id}

); } }