zustand debug

dev/chat
Lei OT 2 years ago
parent a5dade92e6
commit 3a7d293e02

@ -3,6 +3,7 @@ import { RealTimeAPI } from '@/lib/realTimeAPI';
import { olog, isEmpty } from '@/utils/utils'; import { olog, isEmpty } from '@/utils/utils';
import { receivedMsgTypeMapped } from '@/lib/msgUtils'; import { receivedMsgTypeMapped } from '@/lib/msgUtils';
import { fetchConversationsList, fetchTemplates } from '@/actions/ConversationActions'; 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://202.103.68.144:8888/whatever/';
// const WS_URL = 'ws://120.79.9.217:10022/whatever/'; // const WS_URL = 'ws://120.79.9.217:10022/whatever/';
@ -63,6 +64,7 @@ export const websocketSlice = (set, get) => ({
realtimeAPI.onMessage(handleMessage); realtimeAPI.onMessage(handleMessage);
realtimeAPI.onCompletion(() => addError('Connection broken')); realtimeAPI.onCompletion(() => addError('Connection broken'));
olog('Connecting to websocket...', realtimeAPI)
setWebsocket(realtimeAPI); setWebsocket(realtimeAPI);
}, },
disconnectWebsocket: () => { disconnectWebsocket: () => {
@ -235,7 +237,7 @@ export const messageSlice = (set, get) => ({
}, },
}); });
export const useConversationStore = create((set, get) => ({ export const useConversationStore = create(devtools((set, get) => ({
...initialConversationState, ...initialConversationState,
...websocketSlice(set, get), ...websocketSlice(set, get),
...conversationSlice(set, get), ...conversationSlice(set, get),
@ -257,6 +259,6 @@ export const useConversationStore = create((set, get) => ({
const templates = await fetchTemplates(); const templates = await fetchTemplates();
setTemplates(templates); setTemplates(templates);
}, },
})); })));
// window.store = useConversationStore; // debug: // window.store = useConversationStore; // debug:
export default useConversationStore; export default useConversationStore;

Loading…
Cancel
Save