perf: only load posts once

isekai-main
Barış Soner Uşaklı 3 years ago
parent 63976c42fe
commit 9fbb3b11ef

@ -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);

Loading…
Cancel
Save