From 461e95d8d67c1f0d937ec3f1e9c34a13fc37f304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sat, 15 Jun 2024 14:17:48 -0400 Subject: [PATCH] perf: dont make db call if posts is already loaded client side --- public/src/modules/navigator.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index 5111b47e95..8c557985c3 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -183,7 +183,10 @@ define('navigator', [ async function updateThumbTimestampToIndex(thumb, index) { const el = thumb.find('.thumb-timestamp'); if (el.length) { - const timestamp = await getPostTimestampByIndex(index); + const postAtIndex = ajaxify.data.posts.find( + p => parseInt(p.index, 10) === Math.max(0, parseInt(index, 10) - 1) + ); + const timestamp = postAtIndex ? postAtIndex.timestamp : await getPostTimestampByIndex(index); el.attr('title', utils.toISOString(timestamp)).timeago(); } } @@ -450,7 +453,6 @@ define('navigator', [ } count = value; navigator.updateTextAndProgressBar(); - setThumbToIndex(index); toggle(count > 0); };