From 4fefd7298c843862f00ada167029fbcfd3db5461 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 6 Feb 2023 22:29:17 +0000 Subject: [PATCH] chore: hide note creator plus on settings pages --- src/Pages/Layout.tsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Pages/Layout.tsx b/src/Pages/Layout.tsx index d3418ae9..3fc74db1 100644 --- a/src/Pages/Layout.tsx +++ b/src/Pages/Layout.tsx @@ -1,7 +1,7 @@ import "./Layout.css"; -import { useEffect, useState } from "react" +import { useEffect, useMemo, useState } from "react" import { useDispatch, useSelector } from "react-redux"; -import { Outlet, useNavigate } from "react-router-dom"; +import { Outlet, useLocation, useNavigate } from "react-router-dom"; import Envelope from "Icons/Envelope"; import Bell from "Icons/Bell"; import Search from "Icons/Search"; @@ -22,8 +22,8 @@ import { NoteCreator } from "Element/NoteCreator"; import Plus from "Icons/Plus"; import { RelaySettings } from "Nostr/Connection"; - export default function Layout() { + const location = useLocation(); const [show, setShow] = useState(false) const dispatch = useDispatch(); const navigate = useNavigate(); @@ -34,11 +34,15 @@ export default function Layout() { const pub = useEventPublisher(); useLoginFeed(); + const shouldHideNoteCreator = useMemo(() => { + const hideNoteCreator = ["/settings"] + return hideNoteCreator.some(a => location.pathname.startsWith(a)); + }, [location]); + useEffect(() => { System.nip42Auth = pub.nip42Auth }, [pub]) - useEffect(() => { System.UserDb = usingDb; }, [usingDb]) @@ -184,10 +188,12 @@ export default function Layout() { - - + {!shouldHideNoteCreator && (<> + + + )} ) }