Исправить обновление непрочитанных в UI

This commit is contained in:
AidarKC
2026-09-10 12:18:39 +03:00
parent 3a466b4c38
commit 107f85b818
7 changed files with 112 additions and 13 deletions
+6 -1
View File
@@ -360,12 +360,17 @@ function createChannelReadTracker({
const root = getChannelScrollRoot();
const viewportHeight = root?.clientHeight || window.innerHeight || document.documentElement.clientHeight || 0;
const thresholdTop = Math.max(0, Math.round(viewportHeight * unreadAnchorFraction));
const visibleBottom = Math.max(thresholdTop, viewportHeight - 24);
let seen = safeInitialSeenCount;
for (const card of cards) {
const localNumber = Number(card.dataset.localNumber || 0);
if (!Number.isFinite(localNumber) || localNumber <= 0) continue;
const rect = card.getBoundingClientRect();
if (rect.top > thresholdTop + 1) break;
if (rect.top > visibleBottom) break;
if (rect.bottom < 0) {
seen = Math.max(seen, localNumber);
continue;
}
seen = Math.max(seen, localNumber);
}
return Math.max(safeInitialSeenCount, Math.min(seen, safeMessagesCount));