1
Fork 0
mirror of https://github.com/Steffo99/todocolors.git synced 2024-11-25 17:54:18 +00:00

Hide task editor while websocket is not open

This commit is contained in:
Steffo 2023-08-05 21:39:20 +02:00
parent 3d60ede6a2
commit 048899b9ad
Signed by: steffo
GPG key ID: 2A24051445686895

View file

@ -7,7 +7,7 @@ import {faAdd} from "@fortawesome/free-solid-svg-icons"
export function BoardTaskEditor({className}: {className?: string}) { export function BoardTaskEditor({className}: {className?: string}) {
const {editedTask, send, setEditedTaskText} = useManagedBoard() const {editedTask, send, setEditedTaskText, websocketState} = useManagedBoard()
const submitTask = useCallback((e: FormEvent) => { const submitTask = useCallback((e: FormEvent) => {
e.preventDefault(); e.preventDefault();
@ -15,6 +15,10 @@ export function BoardTaskEditor({className}: {className?: string}) {
setEditedTaskText("") setEditedTaskText("")
}, [send, editedTask]) }, [send, editedTask])
if(websocketState != WebSocket.OPEN) {
return null
}
return ( return (
<form onSubmit={submitTask} className={cn(style.editorForm, className)}> <form onSubmit={submitTask} className={cn(style.editorForm, className)}>
<EditorTextInput/> <EditorTextInput/>