Changeset 59f0170 in Klonkt for src/routes/posts.js
- Timestamp:
- 06/24/2026 02:26:32 PM (3 months ago)
- Branches:
- main
- Children:
- dc8e9bd
- Parents:
- 2e9773f
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r2e9773f r59f0170 710 710 } 711 711 712 // Comments: top-level + replies. Two-pass build: fetch all approved 713 // comments for the post, then group replies under their parent. 714 const commentRows = db.prepare(` 715 SELECT c.id, c.parent_comment_id, c.content, c.status, c.created_at, 716 c.author_id, u.username AS author_username, 717 COALESCE(u.avatar_url, (SELECT profile_photo FROM sites WHERE owner_id = u.id AND profile_photo IS NOT NULL ORDER BY is_primary DESC, created_at ASC LIMIT 1)) AS author_avatar 718 FROM comments c JOIN users u ON u.id = c.author_id 719 WHERE c.post_id = ? AND c.status = 'approved' 720 ORDER BY c.created_at ASC 721 `).all(post.id); 722 const topLevel = []; 723 const repliesById = new Map(); 724 for (const c of commentRows) { 725 if (c.parent_comment_id) { 726 if (!repliesById.has(c.parent_comment_id)) repliesById.set(c.parent_comment_id, []); 727 repliesById.get(c.parent_comment_id).push(c); 728 } else { 729 topLevel.push(c); 730 } 731 } 732 for (const c of topLevel) c.replies = repliesById.get(c.id) || []; 733 const totalComments = commentRows.length; 712 // Native comments removed: social interaction is fediverse-only (see the 713 // "From the fediverse" section below). 734 714 735 715 // Prev / next chronological (kept for back-compat — "post-nav" feature … … 818 798 olderPost, 819 799 relatedPosts, 820 comments: topLevel,821 totalComments,822 800 fediverse, 823 801 canManageSite,
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)