"use client"; // Who's online in T5DE, kept live: the page renders the list, then this follows the API's event stream. import Link from "next/link"; import { useEffect, useState } from "react"; import { Initial, Outfit, Tag } from "@/components/status"; import { Since } from "@/components/time"; import type { OnlineEntry } from "@/lib/api"; export function OnlineList({ initial, moderator = false }: { initial: OnlineEntry[]; moderator?: boolean }) { const [online, setOnline] = useState(initial); const [live, setLive] = useState(false); useEffect(() => { const events = new EventSource("/api/v1/online/events"); events.addEventListener("online", (e) => { setOnline((JSON.parse(e.data) as { online: OnlineEntry[] }).online); setLive(true); }); events.addEventListener("error", () => setLive(false)); return () => events.close(); }, []); return (
{live ? "Live" : "Connecting…"} {online.length} {online.length === 1 ? "account" : "accounts"}
{online.length === 0 ? (

Nobody is showing that they're online right now.

) : ( )}
); }