From 47fca0313f9cb58606e8fe3cc1247dc6c2cfc43a Mon Sep 17 00:00:00 2001 From: Lei OT Date: Wed, 7 Feb 2024 10:44:14 +0800 Subject: [PATCH] zustand debug --- src/stores/ConversationStore.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stores/ConversationStore.js b/src/stores/ConversationStore.js index e164c17..904be28 100644 --- a/src/stores/ConversationStore.js +++ b/src/stores/ConversationStore.js @@ -3,6 +3,7 @@ import { RealTimeAPI } from '@/lib/realTimeAPI'; import { olog, isEmpty } from '@/utils/utils'; import { receivedMsgTypeMapped } from '@/lib/msgUtils'; import { fetchConversationsList, fetchTemplates } from '@/actions/ConversationActions'; +import { devtools } from 'zustand/middleware'; // const WS_URL = 'ws://202.103.68.144:8888/whatever/'; // const WS_URL = 'ws://120.79.9.217:10022/whatever/'; @@ -63,6 +64,7 @@ export const websocketSlice = (set, get) => ({ realtimeAPI.onMessage(handleMessage); realtimeAPI.onCompletion(() => addError('Connection broken')); + olog('Connecting to websocket...', realtimeAPI) setWebsocket(realtimeAPI); }, disconnectWebsocket: () => { @@ -235,7 +237,7 @@ export const messageSlice = (set, get) => ({ }, }); -export const useConversationStore = create((set, get) => ({ +export const useConversationStore = create(devtools((set, get) => ({ ...initialConversationState, ...websocketSlice(set, get), ...conversationSlice(set, get), @@ -257,6 +259,6 @@ export const useConversationStore = create((set, get) => ({ const templates = await fetchTemplates(); setTemplates(templates); }, -})); +}))); // window.store = useConversationStore; // debug: export default useConversationStore;