diff --git a/src/views/ChatView.vue b/src/views/ChatView.vue index 7540db2..069269e 100644 --- a/src/views/ChatView.vue +++ b/src/views/ChatView.vue @@ -513,16 +513,23 @@ const deleteMessage = async (messageId) => { } }; -const handleMessagesReadByOther = ({ conversationId: readConversationId, readerId }) => { +const handleMessagesReadByOther = ({ conversationId: readConversationId, readerId, status }) => { if (readConversationId === conversationId.value) { console.log(`[ChatView] Сообщения в диалоге ${readConversationId} прочитаны пользователем ${readerId}`); messages.value = messages.value.map(msg => { if (msg.sender?._id === currentUser.value?._id) { + // Обновляем массив readBy const updatedReadBy = msg.readBy ? [...msg.readBy] : []; if (!updatedReadBy.includes(readerId)) { updatedReadBy.push(readerId); } - return { ...msg, readBy: updatedReadBy }; + + // Обновляем статус сообщения на 'read' + return { + ...msg, + readBy: updatedReadBy, + status: 'read' + }; } return msg; }); @@ -655,13 +662,30 @@ const formatMessageTimestamp = (timestamp) => { }; const getMessageStatusIcon = (message) => { + // Приоритет отдаем полю status, если оно есть + if (message.status) { + switch (message.status) { + case 'sending': + return 'bi bi-clock'; + case 'delivered': + return 'bi bi-check2'; + case 'read': + return 'bi bi-check2-all'; + default: + return 'bi bi-check2'; + } + } + + // Для обратной совместимости проверяем старую логику, если поле status не установлено if (message.isSending) { return 'bi bi-clock'; } + const otherParticipant = getOtherParticipant(); if (otherParticipant && message.readBy && message.readBy.includes(otherParticipant._id)) { return 'bi bi-check2-all'; } + return 'bi bi-check2'; };