diff --git a/src/App.vue b/src/App.vue
index ecd8e83..b04fc88 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -77,8 +77,12 @@ const handleNewMessage = (message) => {
conversationId: message.conversationId
});
+ // ВАЖНО: Правильно сравниваем ID отправителя
+ // message.sender может быть как объектом, так и строкой ID
+ const senderId = typeof message.sender === 'object' ? message.sender._id : message.sender;
+
// ВАЖНО: Увеличиваем счетчик ТОЛЬКО если сообщение пришло от другого пользователя
- if (message.sender !== user.value?._id) {
+ if (senderId !== user.value?._id) {
const conversation = conversations.value.find(c => c._id === message.conversationId);
if (conversation) {
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
diff --git a/src/views/ChatListView.vue b/src/views/ChatListView.vue
index c7ca1e9..573001b 100644
--- a/src/views/ChatListView.vue
+++ b/src/views/ChatListView.vue
@@ -54,9 +54,10 @@
{{ getOtherParticipantName(conversation) || 'Собеседник' }}
{{ formatTimestamp(conversation.updatedAt) }}
+
{{ conversation.unreadCount < 100 ? conversation.unreadCount : '99+' }}
@@ -223,9 +224,12 @@ const handleNewMessageEvent = (message) => {
conversation.lastMessage = message;
conversation.updatedAt = new Date().toISOString();
+ // ВАЖНО: Правильно сравниваем ID отправителя
+ // message.sender может быть как объектом, так и строкой ID
+ const senderId = typeof message.sender === 'object' ? message.sender._id : message.sender;
+
// ВАЖНО: Увеличиваем счетчик ТОЛЬКО если сообщение пришло от другого пользователя
- // И НЕ увеличиваем, если сообщение отправили мы сами
- if (message.sender !== user.value._id) {
+ if (senderId !== user.value._id) {
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
console.log('[ChatListView] Увеличен счетчик непрочитанных для диалога:', message.conversationId, 'новый счетчик:', conversation.unreadCount);
} else {
@@ -617,10 +621,11 @@ const getDialogsCountText = (count) => {
/* Контейнер времени и индикатора */
.timestamp-container {
+ position: relative;
display: flex;
flex-direction: column;
align-items: flex-end;
- gap: 0.25rem;
+ /* Убираем gap, чтобы индикатор не создавал пространства */
}
.timestamp {
@@ -629,8 +634,12 @@ const getDialogsCountText = (count) => {
flex-shrink: 0;
}
-/* Новый индикатор непрочитанных сообщений под временем */
-.unread-badge-under-time {
+/* Плавающий индикатор - абсолютное позиционирование */
+.unread-badge-floating {
+ position: absolute;
+ top: 100%; /* Позиционируем под временем */
+ right: 0;
+ margin-top: 2px; /* Небольшой отступ от времени */
background: linear-gradient(135deg, #ff6b6b, #ff5252);
color: white;
font-size: 0.6rem;
@@ -645,6 +654,7 @@ const getDialogsCountText = (count) => {
box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
border: 1.5px solid white;
animation: subtle-pulse 2s ease-in-out infinite;
+ z-index: 1;
}
/* Адаптивные стили */