import type React from "react"; import { ChangeEvent, useState } from "react"; import { AddLocationIcon, IconButton, majorScale, Pane, Popover, SendMessageIcon, TextInputField, Tooltip, } from "evergreen-ui"; import { useDevice } from "@core/providers/useDevice.js"; import type { Channel } from "@core/stores/deviceStore.js"; import { Message } from "@pages/Messages/Message.js"; import { NewLocationMessage } from "@pages/Messages/NewLocationMessage.js"; export interface ChannelChatProps { channel: Channel; } export const ChannelChat = ({ channel }: ChannelChatProps): JSX.Element => { const { nodes, connection, ackMessage } = useDevice(); const [currentMessage, setCurrentMessage] = useState(""); const sendMessage = (): void => { void connection?.sendText( currentMessage, undefined, true, channel.config.index, (id) => { ackMessage(channel.config.index, id); return Promise.resolve(); } ); setCurrentMessage(""); }; return ( {channel.messages.map((message, index) => ( node.data.num === message.message.packet.from )?.data } /> ))}
{ e.preventDefault(); sendMessage(); }} > ): void => { setCurrentMessage(e.target.value); }} />
}>
); };