фикс реадктирования сообщений
This commit is contained in:
parent
e147959928
commit
b2264d834b
@ -34,6 +34,9 @@ const io = new Server(server, { // <--- Инициализация socket.io
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Сделать экземпляр io доступным в запросах
|
||||||
|
app.set('io', io);
|
||||||
|
|
||||||
// Подключение к базе данных - проверяем, что импортировали функцию
|
// Подключение к базе данных - проверяем, что импортировали функцию
|
||||||
if (typeof connectDBModule === 'function') {
|
if (typeof connectDBModule === 'function') {
|
||||||
try {
|
try {
|
||||||
@ -95,6 +98,16 @@ io.on("connection", (socket) => {
|
|||||||
return activeUsers.find(u => u.userId === userId);
|
return activeUsers.find(u => u.userId === userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
socket.on("joinConversationRoom", (roomId) => {
|
||||||
|
socket.join(roomId);
|
||||||
|
console.log(`[Socket.IO] User ${socket.id} joined room ${roomId}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("leaveConversationRoom", (roomId) => {
|
||||||
|
socket.leave(roomId);
|
||||||
|
console.log(`[Socket.IO] User ${socket.id} left room ${roomId}`);
|
||||||
|
});
|
||||||
|
|
||||||
// Отправка сообщения
|
// Отправка сообщения
|
||||||
socket.on("sendMessage", async ({ senderId, receiverId, text, clientConversationId }) => { // Добавлен clientConversationId, async
|
socket.on("sendMessage", async ({ senderId, receiverId, text, clientConversationId }) => { // Добавлен clientConversationId, async
|
||||||
console.log(`"[Socket.IO] Получено сообщение от ${senderId} для ${receiverId}: "${text}" (попытка для диалога: ${clientConversationId})"`);
|
console.log(`"[Socket.IO] Получено сообщение от ${senderId} для ${receiverId}: "${text}" (попытка для диалога: ${clientConversationId})"`);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<p class="mb-0">{{ item.data.text }}</p>
|
<p class="mb-0">{{ item.data.text }}</p>
|
||||||
<small class="message-timestamp text-muted">
|
<small class="message-timestamp text-muted">
|
||||||
{{ formatMessageTimestamp(item.data.createdAt) }}
|
{{ formatMessageTimestamp(item.data.createdAt) }}
|
||||||
<span v-if="item.data.isEdited && item.data.sender?._id === currentUser?._id" class="ms-1 fst-italic">(изменено)</span>
|
<span v-if="item.data.isEdited" class="ms-1 fst-italic">(изменено)</span>
|
||||||
<span v-if="item.data.sender?._id === currentUser?._id && item.data.isSending" class="ms-1 fst-italic">(отправка...)</span>
|
<span v-if="item.data.sender?._id === currentUser?._id && item.data.isSending" class="ms-1 fst-italic">(отправка...)</span>
|
||||||
<span v-if="item.data.sender?._id === currentUser?._id && !item.data.isSending" class="ms-1">
|
<span v-if="item.data.sender?._id === currentUser?._id && !item.data.isSending" class="ms-1">
|
||||||
<i :class="getMessageStatusIcon(item.data)"></i>
|
<i :class="getMessageStatusIcon(item.data)"></i>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user