| 30 | }; |
| 31 | |
| 32 | const handleSend = async () => { |
| 33 | let conversation = conversationStore.getConversationById(conversationStore.currentConversationId); |
| 34 | if (!conversation) { |
| 35 | const currentConnectionCtx = connectionStore.currentConnectionCtx; |
| 36 | if (!currentConnectionCtx) { |
| 37 | conversation = conversationStore.createConversation(); |
| 38 | } else { |
| 39 | conversation = conversationStore.createConversation(currentConnectionCtx.connection.id, currentConnectionCtx.database?.name); |
| 40 | } |
| 41 | } |
| 42 | if (!value) { |
| 43 | toast.error("Please enter a message."); |
| 44 | return; |
| 45 | } |
| 46 | if (disabled) { |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | setValue(""); |
| 51 | textareaRef.current!.value = ""; |
| 52 | await sendMessage(value); |
| 53 | }; |
| 54 | |
| 55 | const handleKeyDown = (event: React.KeyboardEvent) => { |
| 56 | if (event.key === "Enter" && !event.shiftKey && !isInIME) { |