feat: 消息筛选: 重发

dev/email
Lei OT 2 years ago
parent 88cc2eb3ae
commit 8f3c25723d

@ -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,

@ -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 (
<>
<Image.PreviewGroup className='my-4'>
<Image.PreviewGroup
className='my-4'
preview={{
visible,
onVisibleChange: (value) => {
setVisible(value);
},
toolbarRender: (_, { transform: { scale }, actions: { onRotateLeft, onRotateRight, onZoomOut, onZoomIn }, current }) => (
<Space size={12} className='toolbar-wrapper text-xl px-6 rounded-full bg-[rgba(0,0,0,.1)] *:px-3'>
<RotateLeftOutlined onClick={onRotateLeft} className='cursor-pointer hover:opacity-30' />
<RotateRightOutlined onClick={onRotateRight} className='cursor-pointer hover:opacity-30' />
<ZoomOutOutlined
disabled={scale === 1}
onClick={onZoomOut}
className={[scale === 1 ? 'cursor-not-allowed opacity-30' : '', 'hover:opacity-30 cursor-pointer'].join(' ')}
/>
<ZoomInOutlined
disabled={scale === 50}
onClick={onZoomIn}
className={[scale === 50 ? 'cursor-not-allowed opacity-30' : '', 'hover:opacity-30 cursor-pointer'].join(' ')}
/>
{/* <ShareForwardIcon onClick={() => handleReSend(current)} className='cursor-pointer hover:opacity-30' title='重发' /> */}
</Space>
),
}}>
<List
className='max-h-96 overflow-y-auto'
itemLayout='vertical'
@ -198,6 +267,26 @@ const MessageListFilter = ({ ...props }) => {
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 && <Empty />} */}
@ -226,6 +315,9 @@ const MessageListFilter = ({ ...props }) => {
<Button key='copyv' onClick={() => handleCopyClick(item.data.uri)} type='link' size='small'>
复制🔗
</Button>
{/* <Button key={'resend'} onClick={() => invokeSendUploadMessage(item)} type='link' size='small'>
重发
</Button> */}
</Flex>
}
/>
@ -274,10 +366,11 @@ const MessageListFilter = ({ ...props }) => {
title={emailOrigin.subject}
// description={`To: ${emailOrigin.toEmail}`}
description={
<Flex justify={'space-between'} className='max-w-full overflow-hidden' >
<Flex justify={'space-between'} className='max-w-full overflow-hidden'>
<div className='flex-auto line-clamp-1 break-all pr-2'>{`To: ${emailOrigin.toEmail}`}</div>
<div className=' basis-32 flex-grow-0 flex-shrink-0'>{item.localDate}</div>
</Flex>}
</Flex>
}
/>
{emailOrigin.abstract}
</List.Item>
@ -288,8 +381,6 @@ const MessageListFilter = ({ ...props }) => {
);
};
const [openPopup, setOpenPopup] = useState(false);
return (
<>
<Popover

Loading…
Cancel
Save