From 43561734cc809431301ec5f6131e6baa4d35813b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Mon, 12 Dec 2022 11:48:00 -0500 Subject: [PATCH] fix(glance-nav): do not enable if postcount is less than bookmark threshold; do not allow unread indicator to go above knob --- public/src/client/topic/glance.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/public/src/client/topic/glance.js b/public/src/client/topic/glance.js index 5089e7f08b..a8023e46a7 100644 --- a/public/src/client/topic/glance.js +++ b/public/src/client/topic/glance.js @@ -91,9 +91,13 @@ function enableHandle() { return { handleEl }; } -function updateUnreadIndicator() { +function updateUnreadIndicator(index) { + if (ajaxify.data.postcount < ajaxify.data.bookmarkThreshold) { + return; + } + const unreadEl = document.querySelector('[component="topic/navigator"] .unread'); - const percentage = 1 - (ajaxify.data.bookmark / ajaxify.data.postcount); + const percentage = 1 - (Math.max(index, ajaxify.data.bookmark) / ajaxify.data.postcount); unreadEl.style.height = `${trackHeight * percentage}px`; } @@ -107,7 +111,7 @@ function repositionHandle(index) { } updateHandleText(); - updateUnreadIndicator(); + updateUnreadIndicator(index); if (index === 0) { handleEl.style.top = 0;