diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index 9ec0883..3ecc0d8 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -411,7 +411,8 @@ const messageSlice = (set, get) => ({ } else if (String(ele.id) === String(message.id)) { // console.log('id', message.id, ele.id) // WABA: 异步的后续状态更新, id已更新为wamid - // console.log('old msg ele', ele); + // console.log('coming msg', message.type, message); + // console.log('old msg ele', ele.type, ele); const renderStatus = message?.data?.status ? { status: { ...ele.data.status, loading: 0, download: true } } : {}; const keepReply = ele.reply ? { reply: ele.reply } : {}; const keepTemplate = ele.template ? { template: ele.template, template_origin: ele.template_origin, text: ele.text } : {}; diff --git a/src/views/Conversations/History/MessagesList.jsx b/src/views/Conversations/History/MessagesList.jsx index 4083a6e..b3f56a9 100644 --- a/src/views/Conversations/History/MessagesList.jsx +++ b/src/views/Conversations/History/MessagesList.jsx @@ -256,7 +256,7 @@ const MessagesList = ({ ...listProps }) => { title={message.whatsapp_msg_type === 'text' ? '' : message.title} text={} copiableDate={true} - dateString={message.dateString || message.localDate} + dateString={`${message.wabaName} - ${message.dateString || message.localDate}`} className={[ 'whitespace-pre-wrap mb-2', message.whatsapp_msg_type === 'sticker' ? 'bg-transparent' : '', diff --git a/src/views/Conversations/Online/Input/InputComposer.jsx b/src/views/Conversations/Online/Input/InputComposer.jsx index 3576f74..5b3feba 100644 --- a/src/views/Conversations/Online/Input/InputComposer.jsx +++ b/src/views/Conversations/Online/Input/InputComposer.jsx @@ -23,7 +23,7 @@ const ButtonStyleClsMapped = 'wai': 'bg-whatsapp shadow shadow-whatsapp-300 hover:!bg-whatsapp-400 active:bg-whatsapp-400 focus:bg-whatsapp-400', }; -const InputComposer = ({ channel, currentActive }) => { +const InputComposer = ({ channel, currentActive, lastWABAMsg = {} }) => { const { message: appMessage, notification: appNotification } = App.useApp(); const [mobile] = useStyleStore((state) => [state.mobile]); @@ -41,7 +41,8 @@ const InputComposer = ({ channel, currentActive }) => { const talkabled = !isEmpty(currentConversation.sn) && websocketOpened; const isExpired = !isEmpty(currentConversation.conversation_expiretime) ? dayjs(currentConversation.conversation_expiretime).add(8, 'hours').isBefore(dayjs()) : true; const gt24h = !isEmpty(currentConversation.last_received_time) ? dayjs().diff(dayjs(currentConversation.last_received_time), 'hour') > 24 : true; - const lt24h = !isEmpty(currentConversation.last_received_time) ? dayjs().diff(dayjs(currentConversation.last_received_time), 'hour') <= 24 : false; + // const lt24h = !isEmpty(currentConversation.last_received_time) ? dayjs().diff(dayjs(currentConversation.last_received_time), 'hour') <= 24 : false; + const lt24h = !isEmpty(lastWABAMsg.date) ? dayjs().diff(dayjs(lastWABAMsg.date), 'hour') <= 24 : false; // lt24h || !isExpired const textabled = talkabled; // && (lt24h || !isExpired); // 只要有一个时间没过期, 目前未知明确规则 const textabled0 = talkabled && (lt24h || !isExpired); // 只要有一个时间没过期, 目前未知明确规则 diff --git a/src/views/Conversations/Online/ReplyWrapper.jsx b/src/views/Conversations/Online/ReplyWrapper.jsx index ef1734f..1aa5a03 100644 --- a/src/views/Conversations/Online/ReplyWrapper.jsx +++ b/src/views/Conversations/Online/ReplyWrapper.jsx @@ -49,6 +49,8 @@ const ReplyWrapper = () => { setActiveChannel(activeKey); }; + const [lastWABAMsg, setLastWABAMsg] = useState({}); + const [referenceMsg] = useConversationStore((state) => [state.referenceMsg]); const [sessionType] = useConversationStore((state) => [state.currentConversation.session_type]); const activeMessages = useConversationStore( @@ -60,6 +62,12 @@ const ReplyWrapper = () => { const channel = thisLastChannel === 'email' ? 'email' : DEFAULT_CHANNEL; setActiveChannel((thisLastChannel || DEFAULT_CHANNEL).toLowerCase()); + // console.time('lastWABAMsg'); + const lastInWABAMsgI = activeMessages.findLastIndex(ele => ele.msg_source === 'WABA' && ele.msg_direction=== 'inbound' && ele.status !== 'failed'); + const lastWABAMsg = lastInWABAMsgI !== -1 ? activeMessages[lastInWABAMsgI] : {}; + setLastWABAMsg(lastWABAMsg); + // console.timeEnd('lastWABAMsg') + return () => {}; }, [activeMessages]); @@ -77,7 +85,7 @@ const ReplyWrapper = () => { key: 'waba', disabled: sessionType === 1, label: mobile ? '' : `商业号(${WABAccountsMapped[whatsAppBusiness]?.verifiedName || '-'})`, icon: , - children: , + children: , }, { key: 'email', label: mobile ? '' : '邮件', icon: , children: }, {