feat: stream list view and tasks (#279)
* first attempt at stream sidebar, tasks, and events * fix folder from root * cleanup folders and events, and condense changes * cleanup and add toggle for sidebar * cleanup * fix nits
This commit was merged in pull request #279.
This commit is contained in:
@@ -2,12 +2,19 @@ import { useEffect } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { Lock } from 'lucide-react';
|
||||
import { isParticleDeleted, type Particle } from '@/api/types';
|
||||
import { useLiveParticle } from '@/hooks/use-particle';
|
||||
import { particlePath } from '@/lib/particle-path';
|
||||
import { particlePath, type ParticlePath } from '@/lib/particle-path';
|
||||
import { Button } from '@/components/ui/button';
|
||||
|
||||
import Layout from '@/features/layout';
|
||||
import { StreamView } from '@/features/particles/stream-view';
|
||||
import { FolderView } from '@/features/particles/folder-view';
|
||||
import { MediaParticleView } from '@/features/particles/media-particle-view';
|
||||
import { TextParticleView } from '@/features/particles/text-particle-view';
|
||||
import { TaskParticleView } from '@/features/particles/task-particle-view';
|
||||
import { FallbackParticleView } from '@/features/particles/fallback-particle-view';
|
||||
import { DeletedParticleView } from '@/features/particles/deleted-particle-view';
|
||||
|
||||
/**
|
||||
* Route-level component for /:networkId/*.
|
||||
@@ -25,9 +32,11 @@ export default function ParticleViewResolver() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-muted-foreground text-sm">Loading...</p>
|
||||
</div>
|
||||
<Layout>
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-muted-foreground text-sm">Loading...</p>
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,25 +44,106 @@ export default function ParticleViewResolver() {
|
||||
// Errors here are almost always Firestore permission-denied — the user lost
|
||||
// access to the network or to a custom-visibility particle. The React Router
|
||||
// stays on the dead route, so without an explicit escape the user is stuck.
|
||||
return <InaccessibleParticle />;
|
||||
return (
|
||||
<Layout>
|
||||
<InaccessibleParticle />
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
// Streams render their own full-screen chrome; folders and leaves live
|
||||
// inside the app Layout (breadcrumbs, full-height column) like the root.
|
||||
switch (particle.type) {
|
||||
case 'stream':
|
||||
return <StreamView streamParticle={particle} path={path} />;
|
||||
case 'folder':
|
||||
return <FolderView folderParticle={particle} path={path} />;
|
||||
return (
|
||||
<Layout>
|
||||
<FolderView folderParticle={particle} path={path} />
|
||||
</Layout>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{particle.type} particle: {particle.id}
|
||||
</p>
|
||||
</div>
|
||||
<Layout>
|
||||
<LeafParticleView
|
||||
particle={particle}
|
||||
containerPath={particlePath(networkId, segments.slice(0, -1))}
|
||||
networkId={networkId}
|
||||
/>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
/**
|
||||
* Standalone view for a leaf particle opened directly (e.g. from a folder),
|
||||
* outside any stream playback: renders the particle's native view with no
|
||||
* auto-advance.
|
||||
*/
|
||||
function LeafParticleView({
|
||||
particle,
|
||||
containerPath,
|
||||
networkId,
|
||||
}: {
|
||||
particle: Particle;
|
||||
containerPath: ParticlePath;
|
||||
networkId: string;
|
||||
}) {
|
||||
const content = (() => {
|
||||
if (isParticleDeleted(particle)) {
|
||||
return (
|
||||
<DeletedParticleView
|
||||
particle={particle}
|
||||
networkId={networkId}
|
||||
paused
|
||||
onEnded={noop}
|
||||
/>
|
||||
);
|
||||
}
|
||||
switch (particle.type) {
|
||||
case 'media':
|
||||
return (
|
||||
<MediaParticleView
|
||||
particle={particle}
|
||||
streamPath={containerPath}
|
||||
paused={false}
|
||||
onEnded={noop}
|
||||
/>
|
||||
);
|
||||
case 'text':
|
||||
return (
|
||||
<TextParticleView
|
||||
particle={particle}
|
||||
streamPath={containerPath}
|
||||
paused
|
||||
onEnded={noop}
|
||||
/>
|
||||
);
|
||||
case 'task':
|
||||
return (
|
||||
<TaskParticleView
|
||||
particle={particle}
|
||||
containerPath={containerPath}
|
||||
paused
|
||||
onEnded={noop}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<FallbackParticleView particle={particle} networkId={networkId} />
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
return (
|
||||
<div className="min-h-0 flex-1 bg-black text-white [--stream-safe-top:2rem] [--stream-safe-bottom:2rem]">
|
||||
{content}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function InaccessibleParticle() {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
Reference in New Issue
Block a user