|
@@ -12,7 +12,7 @@ import {
|
|
actionChatLeft
|
|
actionChatLeft
|
|
} from './chatsReducer'
|
|
} from './chatsReducer'
|
|
|
|
|
|
-// const { io } = require("socket.io-client");
|
|
|
|
|
|
+const { io } = require("socket.io-client");
|
|
|
|
|
|
export const store = createStore ( combineReducers({
|
|
export const store = createStore ( combineReducers({
|
|
// promise: localStoredReducer(promiseReducer, 'promise'),
|
|
// promise: localStoredReducer(promiseReducer, 'promise'),
|
|
@@ -30,24 +30,25 @@ store.dispatch(actionAboutMe())
|
|
store.subscribe(() => console.log(store.getState()))
|
|
store.subscribe(() => console.log(store.getState()))
|
|
|
|
|
|
|
|
|
|
-// const socket = io("ws://chat.fs.a-level.com.ua")
|
|
|
|
|
|
+const socket = io("ws://chat.fs.a-level.com.ua")
|
|
|
|
|
|
-// if (localStorage.authToken) {
|
|
|
|
-// socket.emit('jwt', localStorage.authToken)
|
|
|
|
-// }
|
|
|
|
|
|
+if (localStorage.authToken) {
|
|
|
|
+ socket.emit('jwt', localStorage.authToken)
|
|
|
|
+}
|
|
|
|
|
|
-// socket.on('jwt_ok', (data) => console.log(data))
|
|
|
|
-// socket.on('jwt_fail', (error) => console.log(error))
|
|
|
|
|
|
+socket.on('jwt_ok', (data) => console.log(data))
|
|
|
|
+socket.on('jwt_fail', (error) => console.log(error))
|
|
|
|
|
|
-// socket.on('msg', (msg) => {
|
|
|
|
-// store.dispatch(actionMsgOne(msg))
|
|
|
|
-// })
|
|
|
|
-// socket.on('chat', (chat) => {
|
|
|
|
-// store.dispatch(actionChatOne(chat))
|
|
|
|
-// })
|
|
|
|
-// socket.on('chat_left', (chat) => {
|
|
|
|
-// store.dispatch(actionChatLeft(chat))
|
|
|
|
-// })
|
|
|
|
|
|
+socket.on('msg', (msg) => {
|
|
|
|
+ console.log('пришло смс')
|
|
|
|
+ store.dispatch(actionMsgOne(msg))
|
|
|
|
+})
|
|
|
|
+socket.on('chat', (chat) => {
|
|
|
|
+ store.dispatch(actionChatOne(chat))
|
|
|
|
+})
|
|
|
|
+socket.on('chat_left', (chat) => {
|
|
|
|
+ store.dispatch(actionChatLeft(chat))
|
|
|
|
+})
|
|
|
|
|
|
|
|
|
|
// combineReducers({cart: localStoredReducer(cartReducer, 'cart'),
|
|
// combineReducers({cart: localStoredReducer(cartReducer, 'cart'),
|