Skip to content

Node.js based forum software built for the modern web

perf: dont make db call if posts is already loaded client side

Barış Soner Uşaklı461e95d8d67c
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);
};