bug: reply to

This commit is contained in:
Kieran 2023-01-30 19:58:49 +00:00
parent 462fc60dfe
commit dbc853fd8a
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 29 additions and 29 deletions

View File

@ -21,7 +21,7 @@ export interface NoteCreatorProps {
} }
export function NoteCreator(props: NoteCreatorProps) { export function NoteCreator(props: NoteCreatorProps) {
const { show, setShow } = props const { show, setShow, replyTo, onSend, autoFocus } = props
const publisher = useEventPublisher(); const publisher = useEventPublisher();
const [note, setNote] = useState<string>(); const [note, setNote] = useState<string>();
const [error, setError] = useState<string>(); const [error, setError] = useState<string>();
@ -30,13 +30,13 @@ export function NoteCreator(props: NoteCreatorProps) {
async function sendNote() { async function sendNote() {
if (note) { if (note) {
let ev = props.replyTo ? await publisher.reply(props.replyTo, note) : await publisher.note(note); let ev = replyTo ? await publisher.reply(replyTo, note) : await publisher.note(note);
console.debug("Sending note: ", ev); console.debug("Sending note: ", ev);
publisher.broadcast(ev); publisher.broadcast(ev);
setNote(""); setNote("");
setShow(false); setShow(false);
if (typeof props.onSend === "function") { if (typeof onSend === "function") {
props.onSend(); onSend();
} }
setActive(false); setActive(false);
} }
@ -88,10 +88,10 @@ export function NoteCreator(props: NoteCreatorProps) {
className="note-creator-modal" className="note-creator-modal"
onClose={() => setShow(false)} onClose={() => setShow(false)}
> >
<div className={`flex note-creator ${props.replyTo ? 'note-reply' : ''}`}> <div className={`flex note-creator ${replyTo ? 'note-reply' : ''}`}>
<div className="flex f-col mr10 f-grow"> <div className="flex f-col mr10 f-grow">
<Textarea <Textarea
autoFocus={props.autoFocus} autoFocus={autoFocus}
className={`textarea ${active ? "textarea--focused" : ""}`} className={`textarea ${active ? "textarea--focused" : ""}`}
onChange={onChange} onChange={onChange}
value={note} value={note}
@ -108,7 +108,7 @@ export function NoteCreator(props: NoteCreatorProps) {
Cancel Cancel
</button> </button>
<button type="button" onClick={onSubmit}> <button type="button" onClick={onSubmit}>
{props.replyTo ? 'Reply' : 'Send'} {replyTo ? 'Reply' : 'Send'}
</button> </button>
</div> </div>
</Modal> </Modal>

View File

@ -1,5 +1,5 @@
import "./Layout.css"; import "./Layout.css";
import { useEffect, useMemo } from "react" import { useEffect } 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";

View File

@ -46,7 +46,7 @@ export default function RootPage() {
</div></> : null} </div></> : null}
{followHints()} {followHints()}
<Timeline key={tab} subject={timelineSubect} postsOnly={tab === RootTab.Posts} method={"TIME_RANGE"} /> <Timeline key={tab} subject={timelineSubect} postsOnly={tab === RootTab.Posts} method={"TIME_RANGE"} />
<NoteCreator autoFocus={true} show={show} setShow={setShow} /> <NoteCreator replyTo={undefined} autoFocus={true} show={show} setShow={setShow} />
</> </>
); );
} }