From d6169376cb4b479d771002a973b7c159e2a26190 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 9 May 2024 17:14:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E8=AF=BB=E6=A0=87=E8=AF=86:=20999?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/ConversationStore.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index ea3ce14..3911a4d 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -2,7 +2,7 @@ import { create } from 'zustand'; import { RealTimeAPI } from '@/channel/realTimeAPI'; import { olog, isEmpty } from '@/utils/commons'; import { receivedMsgTypeMapped, handleNotification } from '@/channel/whatsappUtils'; -import { fetchConversationsList, fetchTemplates, fetchConversationsSearch } from '@/actions/ConversationActions'; +import { fetchConversationsList, fetchTemplates, fetchConversationsSearch, UNREAD_MARK } from '@/actions/ConversationActions'; import { devtools } from 'zustand/middleware'; import { WS_URL } from '@/config'; @@ -171,6 +171,7 @@ const conversationSlice = (set, get) => ({ addToConversationList: (newList) => { const { activeConversations, conversationsList } = get(); const conversationsIds = Object.keys(activeConversations); + // const conversationsIds = conversationsList.map((chatItem) => `${chatItem.sn}`); const newConversations = newList.filter((conversation) => !conversationsIds.includes(`${conversation.sn}`)); const newConversationsMapped = newConversations.reduce((r, v) => ({ ...r, [`${v.sn}`]: [] }), {}); @@ -178,7 +179,7 @@ const conversationSlice = (set, get) => ({ const withoutNew = conversationsList.filter((item) => !newListIds.includes(`${item.sn}`)); const mergedList = [...newList, ...withoutNew]; - const refreshTotalNotify = mergedList.reduce((r, c) => r+(c.unread_msg_count === 999 ? 0 : c.unread_msg_count), 0); + const refreshTotalNotify = mergedList.reduce((r, c) => r+(c.unread_msg_count === UNREAD_MARK ? 0 : c.unread_msg_count), 0); return set((state) => ({ conversationsList: mergedList, @@ -237,7 +238,7 @@ const messageSlice = (set, get) => ({ totalNotify: 0, msgListLoading: false, activeConversations: {}, - refreshTotalNotify: () => set((state) => ({ totalNotify: state.conversationsList.reduce((r, c) => r+(c.unread_msg_count === 999 ? 0 : c.unread_msg_count), 0) })), + refreshTotalNotify: () => set((state) => ({ totalNotify: state.conversationsList.reduce((r, c) => r+(c.unread_msg_count === UNREAD_MARK ? 0 : c.unread_msg_count), 0) })), setMsgLoading: (msgListLoading) => set({ msgListLoading }), receivedMessageList: (conversationid, msgList) => set((state) => ({