import "./layout.css"; import { CSSProperties, useEffect, useState, useSyncExternalStore } from "react"; import { Link, Outlet, useLocation, useNavigate } from "react-router-dom"; import { Helmet } from "react-helmet"; import { FormattedMessage } from "react-intl"; import { Menu, MenuItem } from "@szhsin/react-menu"; import { hexToBech32 } from "@snort/shared"; import { Icon } from "@/element/icon"; import { useLogin, useLoginEvents } from "@/hooks/login"; import { Profile } from "@/element/profile"; import { NewStreamDialog } from "@/element/new-stream"; import { LoginSignup } from "@/element/login-signup"; import { Login } from "@/login"; import { useLang } from "@/hooks/lang"; import { AllLocales } from "@/intl"; import { trackEvent } from "@/utils"; import { BorderButton, DefaultButton } from "@/element/buttons"; import Modal from "@/element/modal"; import Logo from "@/element/logo"; export function LayoutPage() { const navigate = useNavigate(); const location = useLocation(); const login = useLogin(); const [showLogin, setShowLogin] = useState(false); const { lang, setLang } = useLang(); useLoginEvents(login?.pubkey, true); useEffect(() => { trackEvent("pageview"); }, [location]); function langSelector() { return (
{lang.includes("-") ? lang.split("-")[0] : lang}
} align="end" gap={5}> {AllLocales.sort().map(l => ( setLang(l)} key={l}> {new Intl.DisplayNames([l], { type: "language", }).of(l)} ))}
); } function loggedIn() { if (!login) return; return ( <> {(!import.meta.env.VITE_SINGLE_PUBLISHER || import.meta.env.VITE_SINGLE_PUBLISHER === login.pubkey) && ( )} } align="end" gap={5}> navigate(`/p/${hexToBech32("npub", login.pubkey)}`)}> navigate("/dashboard")}> navigate("/settings")}> navigate("/widgets")}> Login.logout()}> ); } function loggedOut() { if (login) return; return ( <> setShowLogin(true)}> {showLogin && ( setShowLogin(false)} bodyClassName="my-auto bg-layer-1 rounded-xl overflow-hidden">
setShowLogin(false)} />
)} ); } const styles = {} as CSSProperties; if (login?.color) { (styles as Record)["--primary"] = login.color; } return (
Home - zap.stream
navigate("/")}>
Discord {langSelector()} {loggedIn()} {loggedOut()}
); } function NewVersionBanner() { const newVersion = useSyncExternalStore( c => NewVersion.hook(c), () => NewVersion.snapshot() ); if (!newVersion) return; return (

window.location.reload()} className="btn">
); }