|
@@ -9,12 +9,13 @@ import { actionAboutMe } from './findUserActions'
|
|
import {
|
|
import {
|
|
actionMsgOne,
|
|
actionMsgOne,
|
|
actionChatOne,
|
|
actionChatOne,
|
|
- actionChatLeft
|
|
|
|
|
|
+ actionChatLeft
|
|
} from './chatsReducer'
|
|
} from './chatsReducer'
|
|
|
|
|
|
import {
|
|
import {
|
|
|
|
+ actionGetMsgById,
|
|
actionGetChatById,
|
|
actionGetChatById,
|
|
- actionFullLogout
|
|
|
|
|
|
+ actionFullLogout,
|
|
} from '../actions'
|
|
} from '../actions'
|
|
|
|
|
|
import msgSound from '../assets/msgSound.ogg'
|
|
import msgSound from '../assets/msgSound.ogg'
|
|
@@ -56,7 +57,7 @@ function playAudio(audio) {
|
|
|
|
|
|
|
|
|
|
socket.on('msg', async (msg) => {
|
|
socket.on('msg', async (msg) => {
|
|
- console.log('пришло смс')
|
|
|
|
|
|
+ console.log('пришло смс', msg)
|
|
|
|
|
|
const state = store.getState()
|
|
const state = store.getState()
|
|
const myId = state.auth.payload?.sub?.id
|
|
const myId = state.auth.payload?.sub?.id
|
|
@@ -69,11 +70,14 @@ socket.on('msg', async (msg) => {
|
|
|
|
|
|
await store.dispatch(actionMsgOne(msg))
|
|
await store.dispatch(actionMsgOne(msg))
|
|
|
|
|
|
|
|
+ let msgFull = await store.dispatch(actionGetMsgById(msg._id))
|
|
|
|
+ await store.dispatch(actionMsgOne(msgFull))
|
|
|
|
+
|
|
let chatUpdated = await store.dispatch(actionGetChatById(chatId))
|
|
let chatUpdated = await store.dispatch(actionGetChatById(chatId))
|
|
await store.dispatch(actionChatOne(chatUpdated))
|
|
await store.dispatch(actionChatOne(chatUpdated))
|
|
})
|
|
})
|
|
|
|
|
|
-socket.on('chat', (chat) => {
|
|
|
|
|
|
+socket.on('chat', async (chat) => {
|
|
console.log('нас добавили в чат')
|
|
console.log('нас добавили в чат')
|
|
|
|
|
|
const state = store.getState()
|
|
const state = store.getState()
|
|
@@ -85,9 +89,12 @@ socket.on('chat', (chat) => {
|
|
}
|
|
}
|
|
|
|
|
|
store.dispatch(actionChatOne(chat))
|
|
store.dispatch(actionChatOne(chat))
|
|
|
|
+
|
|
|
|
+ let chatFull = await store.dispatch(actionGetChatById(chat._id))
|
|
|
|
+ await store.dispatch(actionChatOne(chatFull))
|
|
})
|
|
})
|
|
|
|
|
|
-socket.on('chat_left', (chat) => {
|
|
|
|
|
|
+socket.on('chat_left', async (chat) => {
|
|
console.log('нас выкинули из чата')
|
|
console.log('нас выкинули из чата')
|
|
|
|
|
|
const state = store.getState()
|
|
const state = store.getState()
|
|
@@ -100,7 +107,8 @@ socket.on('chat_left', (chat) => {
|
|
}
|
|
}
|
|
store.dispatch(actionChatOne(chat))
|
|
store.dispatch(actionChatOne(chat))
|
|
|
|
|
|
-
|
|
|
|
|
|
+ let chatFull = await store.dispatch(actionGetChatById(chat._id))
|
|
|
|
+ await store.dispatch(actionChatOne(chatFull))
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|