From 2d17b0f3c8d620b64ba8c0b627469fcd0ac5fbc2 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Mon, 6 Nov 2023 20:45:47 +0800 Subject: [PATCH] refactor: msg input in mobile --- src/components/MessageInput/index.tsx | 2 +- src/components/Send/Toolbar.tsx | 2 +- src/components/Send/UploadFileList/index.tsx | 6 ++-- src/components/Send/index.tsx | 34 +++++++++++--------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/MessageInput/index.tsx b/src/components/MessageInput/index.tsx index 3acebced..e19886e3 100644 --- a/src/components/MessageInput/index.tsx +++ b/src/components/MessageInput/index.tsx @@ -84,7 +84,7 @@ export default function MessageInput({ <>
= ({ const isMarkdown = mode == "markdown"; return ( -
+
-
+
{shouldPreviewImage(type) ? ( converting ? ( @@ -63,7 +63,7 @@ export default function UploadFileList({ context, id }: { context: ChatContext; getFileIcon(type, name) )}
-

+

{name}

{formatBytes(size)} diff --git a/src/components/Send/index.tsx b/src/components/Send/index.tsx index 1bbe374d..e1742cae 100644 --- a/src/components/Send/index.tsx +++ b/src/components/Send/index.tsx @@ -13,7 +13,7 @@ import useSendMessage from "@/hooks/useSendMessage"; import useUploadFile from "@/hooks/useUploadFile"; import useUserOperation from "@/hooks/useUserOperation"; import StyledButton from "../styled/Button"; -import TextInput from "../TextInput"; +// import TextInput from "../TextInput"; import Replying from "./Replying"; import Toolbar from "./Toolbar"; import UploadFileList from "./UploadFileList"; @@ -80,22 +80,24 @@ const Send: FC = ({ } }; const handleSendMessage = async () => { - if (!id || !msg.text.trim()) return; - // send text msgs + if (!id) return; if (editorRef.current) { editorRef.current.reset(); } - const { text, mentions } = msg; - const properties = { mentions }; - properties.local_id = +new Date(); - await sendMessage({ - id, - reply_mid: replying_mid, - type: "text", - content: text, - from_uid, - properties - }); + if (msg.text.trim()) { + // send text msg + const { text, mentions } = msg; + const properties = { mentions }; + properties.local_id = +new Date(); + await sendMessage({ + id, + reply_mid: replying_mid, + type: "text", + content: text, + from_uid, + properties + }); + } // send files if (uploadFiles.length !== 0) { uploadFiles.forEach((fileInfo) => { @@ -154,11 +156,11 @@ const Send: FC = ({ return ( <> {/* mobile input */} - + {/* */} {/* PC input */}