Files
EpicNext-Cms/src/components/live-online-count.tsx
T
openhands a6e808a099
CI / check (push) Successful in 4m10s
CI / preflight (push) Skipped
CI / deploy (push) Successful in 2m43s
perf(landing): share one SSE socket for online counters, respect reduced motion
Header and hero/stats counters each opened their own EventSource to the
online-count stream; a shared subscriber now opens a single socket and
multicasts to every mounted counter. The entrance count-up animation skips
its requestAnimationFrame loop when the user prefers reduced motion.
2026-09-18 12:57:52 +02:00

23 lines
519 B
TypeScript

"use client";
import { useTranslations } from "next-intl";
import { useOnlineCount } from "@/lib/online-count-sse";
/**
* Live online user counter. Shares a single SSE connection (see
* `useOnlineCount`) so the whole page uses one socket instead of one per
* counter.
*/
export function LiveOnlineCount({
initial,
hotelName,
}: {
initial: number;
hotelName: string;
}) {
const t = useTranslations("header");
const count = useOnlineCount(initial);
return <>{t("online", { count, hotel: hotelName })}</>;
}