import { useLocation } from "react-router-dom"; import React, { useCallback, useEffect, useState } from "react"; import classNames from "classnames"; import { LogoHeader } from "@/Pages/Layout/LogoHeader"; import { RootTabs } from "@/Element/Feed/RootTabs"; import NotificationsHeader from "@/Pages/Layout/NotificationsHeader"; import { NostrLink, NostrPrefix, parseNostrLink } from "@snort/system"; import { bech32ToHex } from "@/SnortUtils"; import { useEventFeed } from "@snort/system-react"; import { FormattedMessage } from "react-intl"; import DisplayName from "@/Element/User/DisplayName"; export function Header() { const location = useLocation(); const showRootTabs = location.pathname === "/"; const pageName = location.pathname.split("/")[1]; const [nostrLink, setNostrLink] = useState(); const scrollUp = useCallback(() => { window.scrollTo({ top: 0, behavior: "instant" }); }, []); useEffect(() => { try { setNostrLink(parseNostrLink(pageName)); } catch (e) { setNostrLink(undefined); } }, [pageName]); let title: React.ReactNode = {pageName}; if (nostrLink) { if (nostrLink.type === NostrPrefix.Event || nostrLink.type === NostrPrefix.Note) { title = ; } else if (nostrLink.type === NostrPrefix.PublicKey || nostrLink.type === NostrPrefix.Profile) { title = ; } } return (
{showRootTabs && } {!showRootTabs && (
{title}
)}
); } function NoteTitle({ link }: { link: NostrLink }) { const ev = useEventFeed(link); if (!ev.data?.pubkey) { return ; } return ( <> }} /> ); }