fix(前端): 会话过期提示: 仅使用WABA渠道计算

dev/supplier-email-drawer
Lei OT 9 months ago
parent 8b84d3aaca
commit 56afea4d75

@ -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 } : {};

@ -256,7 +256,7 @@ const MessagesList = ({ ...listProps }) => {
title={message.whatsapp_msg_type === 'text' ? '' : message.title}
text={<RenderText str={message?.text || ''} className={message.status === 'failed' ? 'line-through text-neutral-400' : ''} template={message.template} />}
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' : '',

@ -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); // ,

@ -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: <WABIcon />,
children: <InputComposer currentActive={activeChannel === 'waba'} channel={'waba'} />,
children: <InputComposer currentActive={activeChannel === 'waba'} channel={'waba'} lastWABAMsg={lastWABAMsg} />,
},
{ key: 'email', label: mobile ? '' : '邮件', icon: <MailOutlined className='text-indigo-500' />, children: <EmailComposer currentActive={activeChannel === 'email'} /> },
{

Loading…
Cancel
Save