фикс
This commit is contained in:
parent
c14811bdac
commit
49eaf17c34
@ -513,16 +513,23 @@ const deleteMessage = async (messageId) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMessagesReadByOther = ({ conversationId: readConversationId, readerId }) => {
|
const handleMessagesReadByOther = ({ conversationId: readConversationId, readerId, status }) => {
|
||||||
if (readConversationId === conversationId.value) {
|
if (readConversationId === conversationId.value) {
|
||||||
console.log(`[ChatView] Сообщения в диалоге ${readConversationId} прочитаны пользователем ${readerId}`);
|
console.log(`[ChatView] Сообщения в диалоге ${readConversationId} прочитаны пользователем ${readerId}`);
|
||||||
messages.value = messages.value.map(msg => {
|
messages.value = messages.value.map(msg => {
|
||||||
if (msg.sender?._id === currentUser.value?._id) {
|
if (msg.sender?._id === currentUser.value?._id) {
|
||||||
|
// Обновляем массив readBy
|
||||||
const updatedReadBy = msg.readBy ? [...msg.readBy] : [];
|
const updatedReadBy = msg.readBy ? [...msg.readBy] : [];
|
||||||
if (!updatedReadBy.includes(readerId)) {
|
if (!updatedReadBy.includes(readerId)) {
|
||||||
updatedReadBy.push(readerId);
|
updatedReadBy.push(readerId);
|
||||||
}
|
}
|
||||||
return { ...msg, readBy: updatedReadBy };
|
|
||||||
|
// Обновляем статус сообщения на 'read'
|
||||||
|
return {
|
||||||
|
...msg,
|
||||||
|
readBy: updatedReadBy,
|
||||||
|
status: 'read'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
});
|
});
|
||||||
@ -655,13 +662,30 @@ const formatMessageTimestamp = (timestamp) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getMessageStatusIcon = (message) => {
|
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) {
|
if (message.isSending) {
|
||||||
return 'bi bi-clock';
|
return 'bi bi-clock';
|
||||||
}
|
}
|
||||||
|
|
||||||
const otherParticipant = getOtherParticipant();
|
const otherParticipant = getOtherParticipant();
|
||||||
if (otherParticipant && message.readBy && message.readBy.includes(otherParticipant._id)) {
|
if (otherParticipant && message.readBy && message.readBy.includes(otherParticipant._id)) {
|
||||||
return 'bi bi-check2-all';
|
return 'bi bi-check2-all';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'bi bi-check2';
|
return 'bi bi-check2';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user