fix: 消息数重复累计

dev/chat
Lei OT 2 years ago
parent e1ae93822b
commit 396f266a78

@ -306,7 +306,7 @@ const messageSlice = (set, get) => ({
conversationsList.splice(targetIndex, 1);
conversationsList.unshift(newConversation);
return set({
totalNotify: totalNotify + newConversation.unread_msg_count,
totalNotify: totalNotify + (message.sender === 'me' ? 0 : 1),
activeConversations: { ...activeConversations, [String(targetId)]: [...targetMsgs, message] },
conversationsList: [...conversationsList],
currentConversation: {

@ -28,13 +28,18 @@ function AuthApp() {
}, [href])
const totalNotify = useConversationStore((state) => state.totalNotify);
const [connectWebsocket, fetchInitialData, disconnectWebsocket ] = useConversationStore((state) => [
state.connectWebsocket,
state.fetchInitialData,
state.disconnectWebsocket,
]);
useEffect(() => {
if (loginUser.userId > 0) {
useConversationStore.getState().connectWebsocket(loginUser.userId);
useConversationStore.getState().fetchInitialData(loginUser.userId); // userIdStr
connectWebsocket(loginUser.userId);
fetchInitialData(loginUser.userId); // userIdStr
}
return () => {
useConversationStore.getState().disconnectWebsocket();
disconnectWebsocket();
}
}, [])
@ -87,7 +92,7 @@ function AuthApp() {
renderEmpty={() => <Empty description={false} />}
>
<AntApp>
<ErrorBoundary>
<ErrorBoundary>
<Outlet />
</ErrorBoundary>
</AntApp>

Loading…
Cancel
Save