import "./root.css"; import { FormattedMessage } from "react-intl"; import { useCallback } from "react"; import type { NostrEvent } from "@snort/system"; import { VideoTile } from "@/element/video-tile"; import { useLogin } from "@/hooks/login"; import { getHost, getTagValues } from "@/utils"; import { useStreamsFeed } from "@/hooks/live-streams"; export function RootPage() { const login = useLogin(); const { live, planned, ended } = useStreamsFeed(); const mutedHosts = new Set(getTagValues(login?.muted.tags ?? [], "p")); const tags = login?.follows.tags ?? []; const followsHost = useCallback( (ev: NostrEvent) => { return tags.find(t => t.at(1) === getHost(ev)); }, [tags] ); const hashtags = getTagValues(tags, "t"); const following = live.filter(followsHost); const liveNow = live.filter(e => !following.includes(e)); const hasFollowingLive = following.length > 0; const plannedEvents = planned.filter(e => !mutedHosts.has(getHost(e))).filter(followsHost); const endedEvents = ended.filter(e => !mutedHosts.has(getHost(e))); return (
{hasFollowingLive && ( <>

{following.map(e => ( ))}
)} {!hasFollowingLive && (
{live .filter(e => !mutedHosts.has(getHost(e))) .map(e => ( ))}
)} {hashtags.map(t => ( <>

#{t}

{live .filter(e => !mutedHosts.has(getHost(e))) .filter(e => { const evTags = getTagValues(e.tags, "t"); return evTags.includes(t); }) .map(e => ( ))}
))} {hasFollowingLive && liveNow.length > 0 && ( <>

{liveNow .filter(e => !mutedHosts.has(getHost(e))) .map(e => ( ))}
)} {plannedEvents.length > 0 && ( <>

{plannedEvents.map(e => ( ))}
)} {endedEvents.length > 0 && ( <>

{endedEvents.map(e => ( ))}
)}
); }