diff --git a/src/actions/ConversationActions.js b/src/actions/ConversationActions.js index e48059e..cd3d287 100644 --- a/src/actions/ConversationActions.js +++ b/src/actions/ConversationActions.js @@ -4,6 +4,7 @@ import { fetchJSON, postJSON } from '@/utils/request' import { parseRenderMessageList } from '@/lib/msgUtils'; import { API_HOST } from '@/config'; import { isEmpty } from '@/utils/commons'; +import dayjs from 'dayjs'; export const fetchTemplates = async () => { const data = await fetchJSON(`${API_HOST}/listtemplates`); @@ -89,6 +90,7 @@ export const fetchConversationsSearch = async (params) => { whatsapp_name: `${ele.whatsapp_name || ''}`.trim(), opi_sn: ele.OPI_SN || ele.opi_sn || 0, OPI_Name: `${ele.OPI_Name || ele.opi_name || ''}`.trim(), + dateText: dayjs(ele.last_received_time).format('MM-DD HH:mm'), matchMsgList: parseRenderMessageList((ele.msglist_AsJOSN || [])), // .reverse()), })); return list; diff --git a/src/lib/msgUtils.js b/src/lib/msgUtils.js index 8dc401b..5319bb2 100644 --- a/src/lib/msgUtils.js +++ b/src/lib/msgUtils.js @@ -1,4 +1,5 @@ import { cloneDeep, isEmpty, olog } from "@/utils/utils"; +import dayjs from "dayjs"; import { v4 as uuid } from "uuid"; export const replaceTemplateString = (str, replacements) => { @@ -480,6 +481,7 @@ export const parseRenderMessageList = (messages, conversationid = null) => { type: msgContent.type, ...(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'), localDate: (msg.msgtime || '').replace('T', ' '), from: msgContent.from, sender: msgContent.from, diff --git a/src/views/ChatHistory.jsx b/src/views/ChatHistory.jsx index f355076..328b530 100644 --- a/src/views/ChatHistory.jsx +++ b/src/views/ChatHistory.jsx @@ -316,6 +316,7 @@ function ChatHistory() { subtitle={`${item.OPI_Name || ''} ${item.coli_id || ''}`} date={item.last_received_time} // dateString={item.last_received_time} + dateString={item.dateText} className={String(item.conversationid) === String(selectedConversation.conversationid) ? '__active text-primary bg-neutral-100' : ''} onClick={() => setSelectedConversation(item)} /> @@ -340,7 +341,7 @@ function ChatHistory() { title={item.sender === 'me' ? selectedConversation.OPI_Name || item.senderName : item.senderName} subtitle={item.originText} date={item.msgtime} - // dateString={item.msgtime} + dateString={item.dateText} className={String(item.sn) === String(selectMatch?.sn) ? '__active text-primary bg-neutral-100' : ' bg-white'} onClick={() => handleMatchMsgClick(item)} /> @@ -392,7 +393,7 @@ function ChatHistory() { navigator.clipboard.writeText(message.text); appMessage.success('ε€εΆζεπ'); }, - Component: () =>