You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { useContext } from 'react';
|
|
|
|
import { ConversationContext, useConversations, } from '@/stores/Conversations/ConversationContext';
|
|
|
|
import { AuthContext } from '@/stores/AuthContext';
|
|
|
|
import { RealTimeAPI } from '@/lib/realTimeAPI';
|
|
|
|
|
|
|
|
const WS_URL = 'ws://202.103.68.157:8888/whatever/';
|
|
|
|
|
|
|
|
export const ConversationProvider = ({ children, loginUser, realtimeAPI }) => {
|
|
|
|
|
|
|
|
const conversations = useConversations({loginUser, realtimeAPI});
|
|
|
|
return <ConversationContext.Provider value={conversations}>{children}</ConversationContext.Provider>;
|
|
|
|
};
|
|
|
|
|
|
|
|
// export default ConversationProvider;
|
|
|
|
|
|
|
|
const AuthAndConversationProvider = ({ children }) => {
|
|
|
|
const { loginUser } = useContext(AuthContext);
|
|
|
|
const {userId} = loginUser;
|
|
|
|
const realtimeAPI = new RealTimeAPI({ url: `${WS_URL}?opisn=${userId || ''}&aa=m&_spam=${Date.now().toString()}`, protocol: 'WhatsApp' });
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConversationProvider loginUser={loginUser} realtimeAPI={realtimeAPI} >
|
|
|
|
{children}
|
|
|
|
</ConversationProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AuthAndConversationProvider;
|