import { createSignal, createEffect, For, Show } from "solid-js"; export function HierarchyApp(props) { // props.state contains springs, rivers, streams, trenches, etc. // props.push is the function to push events to LiveView // props.setState can be used for local updates if needed, // but better to just use props.state and fire events. const handleSpringClick = (springId) => { // Optimistic update or just wait for server? // Let's fire event to server to fetch rivers props.push("fetch_rivers", { spring_id: springId }); // We can also update local state to show selection immediately? // But sending `setState` from parent is cleaner. // Wait, the parent hook has `setState`. // We can use a local signal for UI selection state content, // but the data (rivers) must come from server. // Actually, let's just trigger the push. // And ideally we also set activeSpringId in the store. props.setState("activeSpringId", springId); props.setState("activeRiverId", null); props.setState("activeStreamId", null); }; const handleRiverClick = (riverId) => { props.push("fetch_streams", { river_id: riverId }); props.setState("activeRiverId", riverId); // Maybe toggle expansion? }; const handleStreamClick = (streamId) => { props.push("fetch_trenches", { stream_id: streamId }); props.setState("activeStreamId", streamId); }; return (
{/* 1. Springs (Servers) Column */}
{(spring) => ( )}
{/* 2. Rivers & Streams (Channels) Column */}
{/* Header */}
{props.state.springs.find(s => s.id === props.state.activeSpringId)?.name || "Spring"}
{/* Rivers List */}
Loading rivers...
}> {(river) => (
handleRiverClick(river.id)} > v {river.name} +
{/* Streams in this river */}
{(stream) => (
handleStreamClick(stream.id)} class={`px-2 py-1 rounded mx-2 text-gray-400 hover:bg-gray-800 hover:text-gray-100 cursor-pointer flex items-center ${props.state.activeStreamId === stream.id ? "bg-gray-800 text-white font-medium" : "" }`} > # {stream.name}
)}
)}
{/* 3. Main Stream (Chat) Area */}
👋

Select a stream to start chatting

}> {/* Header */}
# {/* Need to find stream name across all rivers? inefficient. Better to store activeStream details? Or just find it. */} Stream Name
{/* Messages */}
{/* Placeholder messages */}
User A 10:30 AM

Welcome to the stream!

Trenches (Threads):
{(trench) => (
↳ {trench.name}
)}
{/* Input */}
); }