Note creator fix
This commit is contained in:
@ -20,19 +20,21 @@ export interface NoteCreatorProps {
|
|||||||
|
|
||||||
export function NoteCreator(props: NoteCreatorProps) {
|
export function NoteCreator(props: NoteCreatorProps) {
|
||||||
const publisher = useEventPublisher();
|
const publisher = useEventPublisher();
|
||||||
const [note, setNote] = useState("");
|
const [note, setNote] = useState<string>();
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState<string>();
|
||||||
const [active, setActive] = useState(false);
|
const [active, setActive] = useState<boolean>(false);
|
||||||
|
|
||||||
async function sendNote() {
|
async function sendNote() {
|
||||||
let ev = props.replyTo ? await publisher.reply(props.replyTo, note) : await publisher.note(note);
|
if (note) {
|
||||||
console.debug("Sending note: ", ev);
|
let ev = props.replyTo ? await publisher.reply(props.replyTo, note) : await publisher.note(note);
|
||||||
publisher.broadcast(ev);
|
console.debug("Sending note: ", ev);
|
||||||
setNote("");
|
publisher.broadcast(ev);
|
||||||
if (typeof props.onSend === "function") {
|
setNote("");
|
||||||
props.onSend();
|
if (typeof props.onSend === "function") {
|
||||||
|
props.onSend();
|
||||||
|
}
|
||||||
|
setActive(false);
|
||||||
}
|
}
|
||||||
setActive(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function attachFile() {
|
async function attachFile() {
|
||||||
@ -86,7 +88,7 @@ export function NoteCreator(props: NoteCreatorProps) {
|
|||||||
{active && note && (
|
{active && note && (
|
||||||
<div className="actions flex f-row">
|
<div className="actions flex f-row">
|
||||||
<div className="attachment flex f-row">
|
<div className="attachment flex f-row">
|
||||||
{error.length > 0 ? <b className="error">{error}</b> : null}
|
{(error?.length ?? 0) > 0 ? <b className="error">{error}</b> : null}
|
||||||
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
|
<FontAwesomeIcon icon={faPaperclip} size="xl" onClick={(e) => attachFile()} />
|
||||||
</div>
|
</div>
|
||||||
<button type="button" className="btn" onClick={onSubmit}>
|
<button type="button" className="btn" onClick={onSubmit}>
|
||||||
|
Reference in New Issue
Block a user