fix: send msg in mobile

This commit is contained in:
Tristan Yang
2023-05-25 11:10:52 +08:00
parent 319cbd9e42
commit 3e5d255d9e
2 changed files with 18 additions and 24 deletions
+6 -12
View File
@@ -48,15 +48,8 @@ const Send: FC<IProps> = ({
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const addLocalFileMessage = useAddLocalFileMessage({ context, to: id }); const addLocalFileMessage = useAddLocalFileMessage({ context, to: id });
// 谁发的 // 谁发的
const { const { from_uid, replying_mid, mode, uploadFiles, channelsData, usersData, uids } =
from_uid, useAppSelector((store) => {
replying_mid = null,
mode,
uploadFiles,
channelsData,
usersData,
uids
} = useAppSelector((store) => {
return { return {
channelsData: store.channels.byId, channelsData: store.channels.byId,
uids: store.users.ids, uids: store.users.ids,
@@ -83,12 +76,13 @@ const Send: FC<IProps> = ({
editor.insertText(emoji); editor.insertText(emoji);
} }
}; };
const handleSendMessage = async () => { const handleSendMessage = async (messages?: any[]) => {
if (!id) return; if (!id) return;
const sendingMsgs = messages ?? msgs;
editor.resetInput(); editor.resetInput();
if (msgs && msgs.length) { if (sendingMsgs && sendingMsgs.length) {
// send text msgs // send text msgs
for await (const msg of msgs) { for await (const msg of sendingMsgs) {
const { type: content_type, content, properties = {} } = msg; const { type: content_type, content, properties = {} } = msg;
if ((content as string).trim() === "") continue; // 空消息不发送 if ((content as string).trim() === "") continue; // 空消息不发送
properties.local_id = properties.local_id ?? +new Date(); properties.local_id = properties.local_id ?? +new Date();
+2 -2
View File
@@ -20,8 +20,8 @@ const TextInput = ({ sendMessage, placeholder }: Props) => {
const handleSend = () => { const handleSend = () => {
if (!currMsg) return; if (!currMsg) return;
// todo // todo
const msg = [{ type: "text", content: currMsg }]; const msgs = [{ type: "text", content: currMsg }];
sendMessage(msg); sendMessage(msgs);
setCurrMsg(""); setCurrMsg("");
}; };