Add GridBuffer component

This commit is contained in:
He4eT 2021-07-19 14:39:17 +05:00 committed by Alexey
commit 752cb60b56
6 changed files with 75 additions and 10 deletions

View file

@ -39,6 +39,7 @@ export default function ({
currentWindowId,
sendMessage
}) {
const [targetWindow, setTargetWindow] = useState(null)
const [inputText, setInputText] = useState('')
const [lastInput, setLastInput] = useState('')
const inputEl = useRef(null)
@ -48,13 +49,18 @@ export default function ({
inputEl.current && inputEl.current.focus()
}, [inputType])
useEffect(() => {
setTargetWindow(
windows
.find(({id}) =>
id === currentWindowId))
}, [currentWindowId, windows])
const send = message => {
sendMessage(
message,
inputType,
windows
.find(({id}) =>
id === currentWindowId))
targetWindow)
setLastInput(message)
setInputText('')
}