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

View File

@ -1,5 +1,5 @@
import "./Layout.css";
import { useEffect, useMemo } from "react"
import { useEffect } from "react"
import { useDispatch, useSelector } from "react-redux";
import { Outlet, useNavigate } from "react-router-dom";
import Envelope from "Icons/Envelope";

View File

@ -46,7 +46,7 @@ export default function RootPage() {
</div></> : null}
{followHints()}
<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} />
</>
);
}