From 49eaf17c3459076a58ac9ab93be12ea58d66e758 Mon Sep 17 00:00:00 2001 From: Professional Date: Sat, 24 May 2025 02:34:45 +0700 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/ChatView.vue | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) 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'; };