* refactor: use interfaces for function params * cleanup message retention code * support open / closed streams - Tabs for viewing separately - Context menu to close / open streams - Update stream particle status field * ui tweak * show stream state in stream-view * ui tweaks * cleanup message retention from orion api
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import {
|
|
ContextMenu,
|
|
ContextMenuContent,
|
|
ContextMenuItem,
|
|
ContextMenuTrigger,
|
|
} from "@/components/ui/context-menu";
|
|
import { CircleCheckBig, CircleDot } from "lucide-react";
|
|
import { updateStreamStatus } from "@/lib/firestore-particles";
|
|
import { toFirestoreDocPath, particlePath } from "@/lib/particle-path";
|
|
import type { StreamParticle } from "@/hooks/use-stream-particles";
|
|
|
|
interface StreamContextMenuProps {
|
|
particle: StreamParticle;
|
|
networkId: string;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export function StreamContextMenu({ particle, networkId, children }: StreamContextMenuProps) {
|
|
const isOpen = particle.status === "open";
|
|
const docPath = toFirestoreDocPath(particlePath(networkId, [particle.id]));
|
|
|
|
const toggleStatus = async () => {
|
|
await updateStreamStatus(docPath, isOpen ? "closed" : "open");
|
|
};
|
|
|
|
return (
|
|
<ContextMenu>
|
|
<ContextMenuTrigger asChild>{children}</ContextMenuTrigger>
|
|
<ContextMenuContent>
|
|
<ContextMenuItem onSelect={toggleStatus}>
|
|
{isOpen ? (
|
|
<>
|
|
<CircleCheckBig className="size-4" />
|
|
Close stream
|
|
</>
|
|
) : (
|
|
<>
|
|
<CircleDot className="size-4 text-green-500" />
|
|
Open stream
|
|
</>
|
|
)}
|
|
</ContextMenuItem>
|
|
</ContextMenuContent>
|
|
</ContextMenu>
|
|
);
|
|
}
|