mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
perf: only load posts once
This commit is contained in:
@@ -179,12 +179,14 @@ define('forum/topic', [
|
||||
return;
|
||||
}
|
||||
let timeoutId = 0;
|
||||
const postCache = {};
|
||||
$('[component="topic"]').on('mouseenter', '[component="post"] a, [component="topic/event"] a', async function () {
|
||||
const link = $(this);
|
||||
|
||||
async function renderPost(pid) {
|
||||
const postData = await socket.emit('posts.getPostSummaryByPid', { pid: pid });
|
||||
const postData = postCache[pid] || await socket.emit('posts.getPostSummaryByPid', { pid: pid });
|
||||
if (postData) {
|
||||
postCache[pid] = postData;
|
||||
const tooltip = await app.parseAndTranslate('partials/topic/post-preview', { post: postData });
|
||||
tooltip.hide().find('.timeago').timeago();
|
||||
tooltip.appendTo($('body')).fadeIn(300);
|
||||
|
||||
Reference in New Issue
Block a user