import { createFileRoute } from "@tanstack/react-router"; import { useTranslation } from "react-i18next"; import { StreamCard } from "../components/stream/stream-card"; import useAvatars from "../hooks/use-avatars"; import { useLiveUsers } from "../hooks/use-live-users"; import { useStore } from "../lib/store"; export const Route = createFileRoute("/")({ component: HomePage, }); function HomePage() { const { t } = useTranslation("common"); const { data: streams, isLoading, error } = useLiveUsers(); const allDids = streams?.map((s) => s.author.did) ?? []; const avatars = useAvatars(allDids); if (streams === undefined && isLoading) { return (
{Array.from({ length: 4 }).map((_, i) => (
))}
); } return (
{error && !streams && (
{t("could-not-load-streams")}
)} {streams && streams.length > 0 && (

{t("live-now-count", { count: streams.length })}

)} {streams && streams.length === 0 && (

{t("no-one-streaming")}

{t("check-back-later")}

)} {streams && streams.length > 0 && (
{streams.map((stream) => ( ))}
)} {!streams && !isLoading && !error && (

{t("hero-title")}

{t("hero-description")}

{t("learn-more")}
)}
); }