From 3c6c41d0be851df95b220bbd7f14bbbd3a57d245 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 25 Nov 2024 11:20:32 +0800 Subject: [PATCH 1/4] =?UTF-8?q?perf:=20=E4=BC=9A=E8=AF=9D=E5=88=97?= =?UTF-8?q?=E8=A1=A8:=20=E7=BD=AE=E9=A1=B6,=20=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/ConversationStore.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index 2148979..e479c71 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -268,8 +268,11 @@ const conversationSlice = (set, get) => ({ const targetId = conversation.sn; const targetIndex = conversationsList.findIndex((ele) => String(ele.sn) === String(targetId)); conversationsList.splice(targetIndex, 1); + const mergedListMapped = groupBy(conversationsList, 'top_state'); return set({ + topList: mergedListMapped['1'] || [], + pageList: mergedListMapped['0'] || [], conversationsList: [...conversationsList], activeConversations: { ...activeConversations, [`${targetId}`]: [] }, currentConversation: {}, @@ -287,11 +290,14 @@ const conversationSlice = (set, get) => ({ unread_msg_count: 0, }) : null; + const mergedListMapped = groupBy(conversationsList, 'top_state'); return set((state) => ({ totalNotify: state.totalNotify - (conversation.unread_msg_count || 0), currentConversation: Object.assign({}, conversation, targetItemFromList), referenceMsg: {}, + topList: mergedListMapped['1'] || [], + pageList: mergedListMapped['0'] || [], conversationsList: [...conversationsList], })); }, @@ -306,7 +312,13 @@ const conversationSlice = (set, get) => ({ ...conversation, }) : null; - return set({ conversationsList: [...conversationsList] }); + const mergedListMapped = groupBy(conversationsList, 'top_state'); + + return set({ + topList: mergedListMapped['1'] || [], + pageList: mergedListMapped['0'] || [], + conversationsList: [...conversationsList] + }); }, }); @@ -379,10 +391,14 @@ const messageSlice = (set, get) => ({ }, }]; } + const mergedList = [...newConversations, ...conversationsList] + const mergedListMapped = groupBy(mergedList, 'top_state'); return set({ + topList: mergedListMapped['1'] || [], + pageList: mergedListMapped['0'] || [], + conversationsList: mergedList, activeConversations: { ...activeConversations, [String(targetId)]: targetMsgs }, - conversationsList: [...newConversations, ...conversationsList], }); }, sentOrReceivedNewMessage: (targetId, message) => { @@ -425,6 +441,8 @@ const messageSlice = (set, get) => ({ // console.log('find in list, i:', targetIndex); // console.log('find in list, chat updated and Top: \n', JSON.stringify(newConversation, null, 2)); // console.log('list updated : \n', JSON.stringify(conversationsList, null, 2)); + const mergedListMapped = groupBy(conversationsList, 'top_state'); + const isCurrent = Number(targetId) === Number(currentConversation.sn); const updatedCurrent = isCurrent ? { @@ -436,6 +454,8 @@ const messageSlice = (set, get) => ({ : {...currentConversation, last_message: message,}; return set({ currentConversation: updatedCurrent, + topList: mergedListMapped['1'] || [], + pageList: mergedListMapped['0'] || [], conversationsList: [...conversationsList], totalNotify: totalNotify + (message.sender === 'me' ? 0 : 1), activeConversations: { ...activeConversations, [String(targetId)]: [...targetMsgs, message] }, From 3215581f14c71c834bc148f359187435ae27d364 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 25 Nov 2024 14:34:56 +0800 Subject: [PATCH 2/4] perf: channels logo --- .../Conversations/Online/Components/BubbleEmail.jsx | 13 +++++++++---- .../Conversations/Online/Components/BubbleIM.jsx | 8 ++++++-- .../Conversations/Online/Components/ChannelLogo.jsx | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/views/Conversations/Online/Components/BubbleEmail.jsx b/src/views/Conversations/Online/Components/BubbleEmail.jsx index 2dbddcd..b422f30 100644 --- a/src/views/Conversations/Online/Components/BubbleEmail.jsx +++ b/src/views/Conversations/Online/Components/BubbleEmail.jsx @@ -11,12 +11,13 @@ const BubbleEmail = ({ onOpenEditor, onOpenEmail, ...message }) => { const RenderText = memo(function renderText({ className, email, sender }) { return (
handlePreview(message)} className={`text-sm leading-5 emoji-text whitespace-pre-wrap cursor-pointer ${className}`} key={'msg-text'}> - {sender === 'me' &&
From: {email.from}
} -
To: {email.to}
+ {/* {sender === 'me' &&
From: {email.from}
} */} + {/*
To: {email.to}
*/}
Subject: {email.subject}

{email.abstract}
-
+
{email.coli_id ? `订单: ${email.coli_id}` : '未绑定订单'}
+ ); }); const handlePreview = (message) => { @@ -47,15 +48,19 @@ const BubbleEmail = ({ onOpenEditor, onOpenEmail, ...message }) => { {...message} key={`${message.from}.${message.id}`} type='text' - title={ message.sender !== 'me' && + title={ <> + {message.sender !== 'me' ? + <> From: {/* {message?.emailOrigin?.fromName} <{message?.emailOrigin.fromEmail}> */} {message.msgOrigin?.from} + : <>To: {message.msgOrigin?.to} + } } diff --git a/src/views/Conversations/Online/Components/BubbleIM.jsx b/src/views/Conversations/Online/Components/BubbleIM.jsx index f639e84..b7d54a0 100644 --- a/src/views/Conversations/Online/Components/BubbleIM.jsx +++ b/src/views/Conversations/Online/Components/BubbleIM.jsx @@ -6,6 +6,7 @@ import { groupBy, isEmpty } from '@/utils/commons'; import useConversationStore from '@/stores/ConversationStore'; import { useShallow } from 'zustand/react/shallow'; import { WABIcon } from '@/components/Icons'; +import ChannelLogo from './ChannelLogo'; const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, setNewChatFormValues, scrollToMessage, focusMsg, ...message }) => { const { message: appMessage } = App.useApp(); @@ -112,9 +113,12 @@ const BubbleIM = ({ handlePreview, handleContactClick, setNewChatModalVisible, s // styles: { backgroundColor: '#ccd4ae' }, notchStyle: { fill: '#ccd4ae' }, // todo: channel[WhatsApp] color '#d9fdd3' replyButton: ['text', 'document', 'image'].includes(message.whatsapp_msg_type) && message.status !== 'failed' ? true : false, + // title: <> Global Highlights, // test: 0 + title: <> Global Highlights, } - : {})} - // notch={false} + : { + title: <>{message.title}, + })} className={[ 'whitespace-pre-wrap', message.whatsapp_msg_type === 'sticker' ? 'bg-transparent' : '', diff --git a/src/views/Conversations/Online/Components/ChannelLogo.jsx b/src/views/Conversations/Online/Components/ChannelLogo.jsx index df08c33..7573dbd 100644 --- a/src/views/Conversations/Online/Components/ChannelLogo.jsx +++ b/src/views/Conversations/Online/Components/ChannelLogo.jsx @@ -7,7 +7,8 @@ const ChannelLogo = ({channel}) => { if (Array.isArray(channel)) { channel = channel[channel.length - 1]; } - switch (channel) { + const _channel = channel.toLowerCase(); + switch (_channel) { case 'waba': return ; case 'wa': From b16e7119e07a821daaf9d832d09c537cb0b51181 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 25 Nov 2024 14:38:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?build:=20=E5=88=A0=E9=99=A4=E4=BE=9D?= =?UTF-8?q?=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 9 ++------- vite.config.js | 3 +++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 14d2990..a05b099 100644 --- a/package.json +++ b/package.json @@ -14,23 +14,17 @@ "@lexical/react": "^0.20.0", "@vonage/client-sdk": "^1.7.2", "antd": "^5.22.2", - "crypto-js": "^4.2.0", "dayjs": "^1.11.13", "dingtalk-jsapi": "^3.0.41", "emoji-picker-react": "^4.12.0", "lexical": "^0.20.0", - "re-resizable": "^6.10.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^6.28.0", "zustand": "^4.5.5", "react-chat-elements": "^12.0.17", - "react-draggable": "^4.4.6", - "react-quill": "^2.0.0", - "react-rnd": "^10.4.13", "rxjs": "^7.8.1", - "uuid": "^9.0.1", - "vite-plugin-pwa": "^0.21.0" + "uuid": "^9.0.1" }, "devDependencies": { "@types/react": "^18.3.12", @@ -46,6 +40,7 @@ "tailwindcss": "^3.4.15", "vite": "^4.5.1", "vite-plugin-css-modules": "^0.0.1", + "vite-plugin-pwa": "^0.21.0", "vite-plugin-svgr": "^4.3.0", "vite-plugin-windicss": "^1.9.3", "windicss": "^3.5.6" diff --git a/vite.config.js b/vite.config.js index b3776a5..7806ee0 100644 --- a/vite.config.js +++ b/vite.config.js @@ -169,6 +169,9 @@ export default defineConfig({ output: { entryFileNames: '[name]/build.[hash].js', manualChunks(id) { + if (id.toLowerCase().includes('lexical')) { + return 'lexical'; + } if (id.includes('node_modules')) { return 'vendor'; // return id.toString().split('node_modules/')[1].split('/')[0].toString(); From 393deffe46dc88100802eec547c569e9ef17e179 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 25 Nov 2024 14:39:26 +0800 Subject: [PATCH 4/4] # --- src/actions/ConversationActions.js | 1 + src/channel/bubbleMsgUtils.js | 2 ++ src/stores/ConversationStore.js | 1 + 3 files changed, 4 insertions(+) diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js index 8c4ec13..ffd7c78 100644 --- a/src/actions/ConversationActions.js +++ b/src/actions/ConversationActions.js @@ -37,6 +37,7 @@ export const fetchConversationsList = async (params) => { intour: '', session_enable: 1, lastactivetime: '', + top_state: '', } const combinedFilterStr = Object.values(pick(params, ['keyword', 'tags', 'olabel', 'intour', 'ostate'])).join('') if (isNotEmpty(combinedFilterStr) || params.session_enable === 0) { diff --git a/src/channel/bubbleMsgUtils.js b/src/channel/bubbleMsgUtils.js index 6733690..8f99233 100644 --- a/src/channel/bubbleMsgUtils.js +++ b/src/channel/bubbleMsgUtils.js @@ -599,6 +599,7 @@ export const parseRenderMessageItem = (msg) => { ...(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', ' '), + dateString: dayjs(msg?.sendTime || msg.createTime).format('MM-DD HH:mm'), from: msg.from, sender: msg.from, senderName: msg?.customerProfile?.name || msg?.fromName || msg?.from || 'me', // msg.from, @@ -670,6 +671,7 @@ export const parseRenderMessageList = (messages) => { ...(typeof whatsappMsgTypeMapped[msgType].type === 'function' ? whatsappMsgTypeMapped[msgType].type(msg) : { type: whatsappMsgTypeMapped[msgType].type || 'text' }), date: msgContent?.sendTime || msg.msgtime || '', dateText: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'), + dateString: dayjs(msgContent?.sendTime || msg.msgtime).format('MM-DD HH:mm'), localDate: (msg.msgtime || '').replace('T', ' '), from: msgContent.from, sender: msgContent.from, diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index e479c71..229856b 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -74,6 +74,7 @@ const tagsSlice = (set) => ({ // 会话筛选 const filterObj = { + pagesize: '', search: '', otype: '', tags: [],