bug: note reply always

closes #189
This commit is contained in:
2023-02-05 12:32:34 +00:00
parent c0cf92ebf3
commit efa765ea84
3 changed files with 101 additions and 102 deletions

View File

@ -1,9 +1,7 @@
import "./NoteCreator.css"; import "./NoteCreator.css";
import { useState } from "react"; import { useState } from "react";
import Attachment from "Icons/Attachment"; import Attachment from "Icons/Attachment";
import Plus from "Icons/Plus";
import useEventPublisher from "Feed/EventPublisher"; import useEventPublisher from "Feed/EventPublisher";
import { openFile } from "Util"; import { openFile } from "Util";
import Textarea from "Element/Textarea"; import Textarea from "Element/Textarea";
@ -97,9 +95,6 @@ export function NoteCreator(props: NoteCreatorProps) {
return ( return (
<> <>
<button className="note-create-button" type="button" onClick={() => setShow(!show)}>
<Plus />
</button>
{show && ( {show && (
<Modal <Modal
className="note-creator-modal" className="note-creator-modal"

View File

@ -1,5 +1,5 @@
import "./Layout.css"; import "./Layout.css";
import { useEffect } from "react" import { useEffect, useState } from "react"
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { Outlet, useNavigate } from "react-router-dom"; import { Outlet, useNavigate } from "react-router-dom";
import Envelope from "Icons/Envelope"; import Envelope from "Icons/Envelope";
@ -18,9 +18,12 @@ import useModeration from "Hooks/useModeration";
import { IndexedUDB, useDb } from "State/Users/Db"; import { IndexedUDB, useDb } from "State/Users/Db";
import { db } from "Db"; import { db } from "Db";
import { bech32ToHex } from "Util"; import { bech32ToHex } from "Util";
import { NoteCreator } from "Element/NoteCreator";
import Plus from "Icons/Plus";
export default function Layout() { export default function Layout() {
const [show, setShow] = useState(false)
const dispatch = useDispatch(); const dispatch = useDispatch();
const navigate = useNavigate(); const navigate = useNavigate();
const { loggedOut, publicKey, relays, notifications, readNotifications, dms, preferences, newUserKey } = useSelector((s: RootState) => s.login); const { loggedOut, publicKey, relays, notifications, readNotifications, dms, preferences, newUserKey } = useSelector((s: RootState) => s.login);
@ -174,8 +177,12 @@ export default function Layout() {
} }
</div> </div>
</header> </header>
<Outlet /> <Outlet />
<button className="note-create-button" type="button" onClick={() => setShow(!show)}>
<Plus />
</button>
<NoteCreator replyTo={undefined} autoFocus={true} show={show} setShow={setShow} />
</div> </div>
) )
} }

View File

@ -4,7 +4,6 @@ import { useSelector } from "react-redux";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { RootState } from "State/Store"; import { RootState } from "State/Store";
import { NoteCreator } from "Element/NoteCreator";
import Timeline from "Element/Timeline"; import Timeline from "Element/Timeline";
import { HexKey } from "Nostr"; import { HexKey } from "Nostr";
import { TimelineSubject } from "Feed/TimelineFeed"; import { TimelineSubject } from "Feed/TimelineFeed";
@ -16,7 +15,6 @@ const RootTab = {
}; };
export default function RootPage() { export default function RootPage() {
const [show, setShow] = useState(false)
const [loggedOut, pubKey, follows] = useSelector<RootState, [boolean | undefined, HexKey | undefined, HexKey[]]>(s => [s.login.loggedOut, s.login.publicKey, s.login.follows]); 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); const [tab, setTab] = useState(RootTab.Posts);
@ -46,7 +44,6 @@ export default function RootPage() {
</div></> : null} </div></> : null}
{followHints()} {followHints()}
<Timeline key={tab} subject={timelineSubect} postsOnly={tab === RootTab.Posts} method={"TIME_RANGE"} window={tab === RootTab.Global ? 60 : undefined} /> <Timeline key={tab} subject={timelineSubect} postsOnly={tab === RootTab.Posts} method={"TIME_RANGE"} window={tab === RootTab.Global ? 60 : undefined} />
<NoteCreator replyTo={undefined} autoFocus={true} show={show} setShow={setShow} />
</> </>
); );
} }