From ce2d1d4527e1225011861a8fd41cd3364aa12dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Tue, 13 Jan 2026 09:46:27 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D1=83=D0=B5=D0=BC=20lastReadTimestamp=20=D0=BA=D0=B0?= =?UTF-8?q?=D0=BA=20fallback=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BA=D1=80?= =?UTF-8?q?=D0=BE=D0=BB=D0=BB=D0=B0=20=D0=BA=20=D0=BF=D0=BE=D1=81=D0=BB?= =?UTF-8?q?=D0=B5=D0=B4=D0=BD=D0=B5=D0=BC=D1=83=20=D0=BF=D1=80=D0=BE=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=D0=BD=D0=BD=D0=BE=D0=BC=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Проблема: lastReadMessageId часто равен 0/null - Решение: используем lastReadTimestamp (API поддерживает оба формата) - Добавлен this.lastReadTimestamp в ChatControllerV2 - Передаем оба параметра из chatDetail.js - anchorValue = lastReadMessageId || lastReadTimestamp - Исправлена поврежденная структура в chatControllerV2.js --- backend/static/js/controllers/chatControllerV2.js | 5 ++++- backend/static/js/pages/chatDetail.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/static/js/controllers/chatControllerV2.js b/backend/static/js/controllers/chatControllerV2.js index 42d98d57..ef01abc1 100644 --- a/backend/static/js/controllers/chatControllerV2.js +++ b/backend/static/js/controllers/chatControllerV2.js @@ -45,6 +45,7 @@ export class ChatControllerV2 { this.scrollElement = options.scrollElement; this.containerId = options.containerId || 'chatScroll'; this.lastReadMessageId = options.lastReadMessageId || null; + this.lastReadTimestamp = options.lastReadTimestamp || null; // Создаем компоненты this.store = new MessageStoreV2({ currentUserId: this.currentUserId }); @@ -114,8 +115,10 @@ export class ChatControllerV2 { try { // 1. Загружаем сообщения + // Используем timestamp как fallback если нет message ID (API поддерживает оба) + const anchorValue = this.lastReadMessageId || this.lastReadTimestamp; const loadResult = await this.loader.loadInitial(this.chatId, { - aroundMessageId: this.lastReadMessageId + aroundMessageId: anchorValue }); // 2. Скрываем контейнер для плавного рендера diff --git a/backend/static/js/pages/chatDetail.js b/backend/static/js/pages/chatDetail.js index 30cbc62e..3e0be5e5 100644 --- a/backend/static/js/pages/chatDetail.js +++ b/backend/static/js/pages/chatDetail.js @@ -183,7 +183,8 @@ async function initializeComponents(config, userWs) { profileUrl: config.profileUrl || '/employees/profile/', detailUrlTemplate: config.detailUrlTemplate || '/employees/detail/0/', messagesUrl: config.messagesUrl, - lastReadTimestamp: config.lastReadMessageId || config.lastReadTimestamp // Используем message_id, fallback на timestamp + lastReadMessageId: config.lastReadMessageId, // ✅ Передаем message_id + lastReadTimestamp: config.lastReadTimestamp // ✅ Fallback на timestamp }); console.log('[ChatDetail] Initializing ChatController...');