feat: Implement server-side comment preloading for improved performance and introduce new comment features including pinned comments, locked threads, and custom emojis.

This commit is contained in:
x
2026-01-25 15:12:57 +01:00
parent 68011c60de
commit bf5996d2ba
6 changed files with 108 additions and 15 deletions

View File

@@ -42,6 +42,26 @@ export default (router, tpl) => {
});
}
// Preload comments for instant rendering (if logged in)
if (req.session) {
data.comments = await f0cklib.getComments(req.params.itemid);
// Also need subscription status? comments.js handles subscription toggle separately but initial state?
// API returns is_subscribed.
// Let's optimize later or just fetch simple comments list.
// Subscription status and is_locked/is_admin might be needed for comments.js to FULLY render without API call.
// But comments.js fetches API mainly for comments list. It also gets is_admin etc.
// If I provide comments list, comments.js skips fetch.
// It uses `this.isAdmin` from DOM. `this.isLocked` from DOM.
// `isSubscribed`? Not in DOM yet.
// I should add `data-is-subscribed` to DOM?
const sub = await f0cklib.getSubscriptionStatus(req.session.id, req.params.itemid);
data.isSubscribed = sub;
data.commentsJSON = Buffer.from(JSON.stringify(data.comments || [])).toString('base64');
} else {
data.comments = [];
data.commentsJSON = Buffer.from('[]').toString('base64');
}
// Inject session into data for the template
// We clone session to avoid unintended side effects or collisions
if (req.session) {