chore: hide note creator plus on settings pages
This commit is contained in:
parent
c928beb174
commit
4fefd7298c
@ -1,7 +1,7 @@
|
|||||||
import "./Layout.css";
|
import "./Layout.css";
|
||||||
import { useEffect, useState } from "react"
|
import { useEffect, useMemo, useState } from "react"
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
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 Envelope from "Icons/Envelope";
|
||||||
import Bell from "Icons/Bell";
|
import Bell from "Icons/Bell";
|
||||||
import Search from "Icons/Search";
|
import Search from "Icons/Search";
|
||||||
@ -22,8 +22,8 @@ import { NoteCreator } from "Element/NoteCreator";
|
|||||||
import Plus from "Icons/Plus";
|
import Plus from "Icons/Plus";
|
||||||
import { RelaySettings } from "Nostr/Connection";
|
import { RelaySettings } from "Nostr/Connection";
|
||||||
|
|
||||||
|
|
||||||
export default function Layout() {
|
export default function Layout() {
|
||||||
|
const location = useLocation();
|
||||||
const [show, setShow] = useState(false)
|
const [show, setShow] = useState(false)
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -34,11 +34,15 @@ export default function Layout() {
|
|||||||
const pub = useEventPublisher();
|
const pub = useEventPublisher();
|
||||||
useLoginFeed();
|
useLoginFeed();
|
||||||
|
|
||||||
|
const shouldHideNoteCreator = useMemo(() => {
|
||||||
|
const hideNoteCreator = ["/settings"]
|
||||||
|
return hideNoteCreator.some(a => location.pathname.startsWith(a));
|
||||||
|
}, [location]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
System.nip42Auth = pub.nip42Auth
|
System.nip42Auth = pub.nip42Auth
|
||||||
}, [pub])
|
}, [pub])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
System.UserDb = usingDb;
|
System.UserDb = usingDb;
|
||||||
}, [usingDb])
|
}, [usingDb])
|
||||||
@ -184,10 +188,12 @@ export default function Layout() {
|
|||||||
</header>
|
</header>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|
||||||
|
{!shouldHideNoteCreator && (<>
|
||||||
<button className="note-create-button" type="button" onClick={() => setShow(!show)}>
|
<button className="note-create-button" type="button" onClick={() => setShow(!show)}>
|
||||||
<Plus />
|
<Plus />
|
||||||
</button>
|
</button>
|
||||||
<NoteCreator replyTo={undefined} autoFocus={true} show={show} setShow={setShow} />
|
<NoteCreator replyTo={undefined} autoFocus={true} show={show} setShow={setShow} />
|
||||||
|
</>)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user