фикс
This commit is contained in:
parent
a14997b84c
commit
8594a7dd0e
11
src/App.vue
11
src/App.vue
@ -71,15 +71,24 @@ const fetchConversations = async () => {
|
||||
|
||||
// Обработчик новых сообщений
|
||||
const handleNewMessage = (message) => {
|
||||
// Если сообщение от другого пользователя, увеличиваем счетчик
|
||||
console.log('[App] Получено новое сообщение:', {
|
||||
sender: message.sender,
|
||||
currentUser: user.value?._id,
|
||||
conversationId: message.conversationId
|
||||
});
|
||||
|
||||
// ВАЖНО: Увеличиваем счетчик ТОЛЬКО если сообщение пришло от другого пользователя
|
||||
if (message.sender !== user.value?._id) {
|
||||
const conversation = conversations.value.find(c => c._id === message.conversationId);
|
||||
if (conversation) {
|
||||
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
|
||||
console.log('[App] Увеличен счетчик в навигации для диалога:', message.conversationId);
|
||||
} else {
|
||||
// Если диалога нет в списке, обновим весь список
|
||||
fetchConversations();
|
||||
}
|
||||
} else {
|
||||
console.log('[App] Сообщение от текущего пользователя, счетчик в навигации не изменяется');
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,15 @@
|
||||
<div class="conversation-info">
|
||||
<div class="conversation-header">
|
||||
<h3 class="user-name">{{ getOtherParticipantName(conversation) || 'Собеседник' }}</h3>
|
||||
<span class="timestamp">{{ formatTimestamp(conversation.updatedAt) }}</span>
|
||||
<div class="timestamp-container">
|
||||
<span class="timestamp">{{ formatTimestamp(conversation.updatedAt) }}</span>
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0"
|
||||
class="unread-badge-under-time"
|
||||
>
|
||||
{{ conversation.unreadCount < 100 ? conversation.unreadCount : '99+' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="last-message">
|
||||
<span v-if="conversation.typing" class="typing-text">
|
||||
@ -69,14 +77,8 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Right side: Unread badge and arrow -->
|
||||
<!-- Right side: только стрелка -->
|
||||
<div class="conversation-right">
|
||||
<span
|
||||
v-if="conversation.unreadCount > 0"
|
||||
class="unread-badge"
|
||||
>
|
||||
{{ conversation.unreadCount < 100 ? conversation.unreadCount : '99+' }}
|
||||
</span>
|
||||
<div class="conversation-arrow">
|
||||
<i class="bi-chevron-right"></i>
|
||||
</div>
|
||||
@ -209,15 +211,25 @@ const formatLastMessage = (conversation) => {
|
||||
|
||||
// Обработка событий
|
||||
const handleNewMessageEvent = (message) => {
|
||||
console.log('[ChatListView] Получено новое сообщение:', {
|
||||
sender: message.sender,
|
||||
currentUser: user.value._id,
|
||||
conversationId: message.conversationId
|
||||
});
|
||||
|
||||
const conversation = conversations.value.find(c => c._id === message.conversationId);
|
||||
if (conversation) {
|
||||
// Обновляем диалог с новым сообщением
|
||||
conversation.lastMessage = message;
|
||||
conversation.updatedAt = new Date().toISOString();
|
||||
|
||||
// Если сообщение пришло от другого пользователя, увеличиваем счетчик непрочитанных
|
||||
// ВАЖНО: Увеличиваем счетчик ТОЛЬКО если сообщение пришло от другого пользователя
|
||||
// И НЕ увеличиваем, если сообщение отправили мы сами
|
||||
if (message.sender !== user.value._id) {
|
||||
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
|
||||
console.log('[ChatListView] Увеличен счетчик непрочитанных для диалога:', message.conversationId, 'новый счетчик:', conversation.unreadCount);
|
||||
} else {
|
||||
console.log('[ChatListView] Сообщение от текущего пользователя, счетчик не изменяется');
|
||||
}
|
||||
|
||||
// Сбрасываем статус печати
|
||||
@ -603,6 +615,38 @@ const getDialogsCountText = (count) => {
|
||||
min-width: 0; /* Для корректной работы text-overflow */
|
||||
}
|
||||
|
||||
/* Контейнер времени и индикатора */
|
||||
.timestamp-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
font-size: 0.75rem;
|
||||
color: #6c757d;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Новый индикатор непрочитанных сообщений под временем */
|
||||
.unread-badge-under-time {
|
||||
background: linear-gradient(135deg, #ff6b6b, #ff5252);
|
||||
color: white;
|
||||
font-size: 0.6rem;
|
||||
font-weight: 700;
|
||||
border-radius: 10px;
|
||||
min-width: 18px;
|
||||
height: 18px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 6px;
|
||||
box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
|
||||
border: 1.5px solid white;
|
||||
animation: subtle-pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Адаптивные стили */
|
||||
@media (max-width: 576px) {
|
||||
.conversation-card {
|
||||
|
Loading…
x
Reference in New Issue
Block a user