zustand debug

dev/chat
Lei OT 1 year ago
parent a5dade92e6
commit 3a7d293e02

@ -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;

Loading…
Cancel
Save