diff --git a/src/channel/whatsappUtils.js b/src/channel/whatsappUtils.js index f347aaf..de8025c 100644 --- a/src/channel/whatsappUtils.js +++ b/src/channel/whatsappUtils.js @@ -507,6 +507,7 @@ export const parseRenderMessageItem = (msg) => { conversationid: msg.conversationid, ...(typeof whatsappMsgTypeMapped[thisMsgType].type === 'function' ? whatsappMsgTypeMapped[thisMsgType].type(msg) : { type: whatsappMsgTypeMapped[thisMsgType].type || 'text' }), // type: whatsappMsgTypeMapped?.[thisMsgType]?.type || 'text', + localDate: (msg?.sendTime || msg?.createTime || '').replace('T', ' '), from: msg.from, sender: msg.from, senderName: msg?.customerProfile?.name || 'me', // msg.from, diff --git a/src/views/Conversations/Online/Components/MessageListFilter.jsx b/src/views/Conversations/Online/Components/MessageListFilter.jsx index 50e0993..f67ec45 100644 --- a/src/views/Conversations/Online/Components/MessageListFilter.jsx +++ b/src/views/Conversations/Online/Components/MessageListFilter.jsx @@ -1,14 +1,28 @@ import { useEffect, useState } from 'react'; -import { App, Button, Popover, Tabs, List, Image, Avatar, Card, Flex } from 'antd'; +import { App, Button, Popover, Tabs, List, Image, Avatar, Card, Flex, Space } from 'antd'; import { FileSearchOutlined, LoadingOutlined } from '@ant-design/icons'; -import { InboxIcon, SendPlaneFillIcon } from '@/components/Icons'; +import { + DownloadOutlined, + LeftOutlined, + RightOutlined, + RotateLeftOutlined, + RotateRightOutlined, + SwapOutlined, + UndoOutlined, + ZoomInOutlined, + ZoomOutOutlined, +} from '@ant-design/icons'; +import { InboxIcon, SendPlaneFillIcon, ShareForwardIcon } from '@/components/Icons'; import { groupBy, stringToColour } from '@/utils/commons'; -import useConversationStore from '@/stores/ConversationStore'; import { useShallow } from 'zustand/react/shallow'; import EmailDetail from './EmailDetail'; import { MESSAGE_PAGE_SIZE, fetchMessagesHistory } from '@/actions/ConversationActions'; import DnDModal from '@/components/DnDModal'; +import useConversationStore from '@/stores/ConversationStore'; import useStyleStore from '@/stores/StyleStore'; +import useAuthStore from '@/stores/AuthStore'; +import { sentMsgTypeMapped, whatsappSupportFileTypes, uploadProgressSimulate } from '@/channel/whatsappUtils'; +import { v4 as uuid } from 'uuid'; const BIG_PAGE_SIZE = MESSAGE_PAGE_SIZE * 10; @@ -18,7 +32,7 @@ const CalColorStyle = (tag, outerStyle = true) => { return { color: `${color}`, ...outerStyleObj }; }; const getVideoName = (vUrl) => { - if ( ! vUrl) return ''; + if (!vUrl) return ''; const url = new URL(vUrl); return url.pathname.split('/').pop(); }; @@ -26,7 +40,12 @@ const getVideoName = (vUrl) => { * 消息记录筛选---------------------------------------------------------------------------------------------------- */ const MessageListFilter = ({ ...props }) => { + const websocket = useConversationStore((state) => state.websocket); + const userId = useAuthStore((state) => state.loginUser.userId); + const sentOrReceivedNewMessage = useConversationStore((state) => state.sentOrReceivedNewMessage); + const [mobile] = useStyleStore((state) => [state.mobile]); + const [openPopup, setOpenPopup] = useState(false); const activeMessages = useConversationStore( useShallow((state) => (state.currentConversation.sn && state.activeConversations[state.currentConversation.sn] ? state.activeConversations[state.currentConversation.sn] : [])) @@ -36,7 +55,7 @@ const MessageListFilter = ({ ...props }) => { const { message: appMessage } = App.useApp(); - const LongList = () => { + const LongList = () => { return <>; }; @@ -73,12 +92,12 @@ const MessageListFilter = ({ ...props }) => { const handleCopyClick = (url) => { try { - navigator.clipboard.writeText(url) + navigator.clipboard.writeText(url); appMessage.success('复制成功😀'); } catch (error) { appMessage.warning('不支持自动复制, 请手动复制'); } - } + }; useEffect(() => { if (activeMessages.length > 0) { @@ -93,9 +112,59 @@ const MessageListFilter = ({ ...props }) => { const Album = () => { const data = historyMessages.filter((item) => item.type === 'photo').reverse(); const byDate = groupBy(data, (item) => item.localDate.slice(0, 10)); + + const [visible, setVisible] = useState(false); + const handleReSend = (currentIndex) => { + console.log('handleReSend', currentIndex, data[currentIndex]); + // todo: 没有先push到窗口上, 导致没有更新 + const item = data[currentIndex]; + const msgObjMerge = { + sender: 'me', + senderName: 'me', + to: currentConversation.whatsapp_phone_number, + date: new Date(), + status: 'waiting', + // ...msgObj, + data: { link: item.data.uri, dataUri: item.data.uri, uri: item.data.uri, loading: 1 }, // ...fileObj.data, + id: `${currentConversation.sn}.${uuid()}`, + type: item.whatsapp_msg_type, + // name: item.title, + }; + const contentToRender = sentMsgTypeMapped[item.type].contentToRender(msgObjMerge); + sentOrReceivedNewMessage(contentToRender.conversationid, contentToRender); + + const contentToSend = sentMsgTypeMapped[item.type].contentToSend(msgObjMerge); + websocket.sendMessage({ ...contentToSend, opi_sn: userId, coli_sn: currentConversation.coli_sn, conversationid: currentConversation.sn }); + setOpenPopup(false); + setVisible(false); + }; return ( <> - + { + setVisible(value); + }, + toolbarRender: (_, { transform: { scale }, actions: { onRotateLeft, onRotateRight, onZoomOut, onZoomIn }, current }) => ( + + + + + + {/* handleReSend(current)} className='cursor-pointer hover:opacity-30' title='重发' /> */} + + ), + }}> { const FileList = () => { const data = historyMessages.filter((item) => item.type === 'file').reverse(); + const invokeSendUploadMessage = (item) => { + const msgObjMerge = { + sender: 'me', + senderName: 'me', + to: currentConversation.whatsapp_phone_number, + date: new Date(), + status: 'waiting', + // ...msgObj, + data: { link: item.data.uri, dataUri: item.data.uri, uri: item.data.uri, loading: 1 }, // ...fileObj.data, + id: `${currentConversation.sn}.${uuid()}`, + type: 'document', + name: item.title, + }; + const contentToRender = sentMsgTypeMapped[msgObjMerge.type].contentToRender(msgObjMerge); + sentOrReceivedNewMessage(contentToRender.conversationid, contentToRender); + + const contentToSend = sentMsgTypeMapped[msgObjMerge.type].contentToSend(msgObjMerge); + websocket.sendMessage({ ...contentToSend, opi_sn: userId, coli_sn: currentConversation.coli_sn, conversationid: currentConversation.sn }); + setOpenPopup(false); + }; return ( <> {/* {data.length === 0 && } */} @@ -226,6 +315,9 @@ const MessageListFilter = ({ ...props }) => { + {/* */} } /> @@ -274,10 +366,11 @@ const MessageListFilter = ({ ...props }) => { title={emailOrigin.subject} // description={`To: ${emailOrigin.toEmail}`} description={ - +
{`To: ${emailOrigin.toEmail}`}
{item.localDate}
-
} +
+ } /> {emailOrigin.abstract} @@ -288,8 +381,6 @@ const MessageListFilter = ({ ...props }) => { ); }; - const [openPopup, setOpenPopup] = useState(false); - return ( <>