import "./Root.css"; import { useState } from "react"; import { useSelector } from "react-redux"; import { Link } from "react-router-dom"; import Tabs, { Tab } from "Element/Tabs"; import { RootState } from "State/Store"; import Timeline from "Element/Timeline"; import { HexKey } from "Nostr"; import { TimelineSubject } from "Feed/TimelineFeed"; const RootTab: Record = { Posts: { text: "Posts", value: 0 }, PostsAndReplies: { text: "Conversations", value: 1 }, Global: { text: "Global", value: 2 }, }; export default function RootPage() { const [loggedOut, pubKey, follows] = useSelector< RootState, [boolean | undefined, HexKey | undefined, HexKey[]] >((s) => [s.login.loggedOut, s.login.publicKey, s.login.follows]); const [tab, setTab] = useState(RootTab.Posts); function followHints() { if (follows?.length === 0 && pubKey && tab !== RootTab.Global) { return ( <> Hmm nothing here.. Checkout New users page to follow some recommended nostrich's! ); } } const isGlobal = loggedOut || tab.value === RootTab.Global.value; const timelineSubect: TimelineSubject = isGlobal ? { type: "global", items: [], discriminator: "all" } : { type: "pubkey", items: follows, discriminator: "follows" }; return ( <>
{pubKey && ( )}
{followHints()} ); }