You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
First of all, thank you for this great piece of software.
I'm creating a website with threaded comments functionality - working kind of like reddit. There is a post, post can have many comments and each comment can have many sub-comments. closure_tree makes working with such setup a breeze but things gets complicated when i want to expose my comments through REST API in a consumer-friendly way.
I'm not able to reverse-engineer it as it seems that the initial comments list is rendered server-side but i'm gonna try to explain what such endpoint should return:
Paginated list of root comments (say, 5 per page)
for each root comment, a paginated list of sub-comments (say, 5 per page again)
reapeat previous step recursively for each child comment until depth = 3
ORIGINAL POST
+-- Comment 1
| +-- Sub comment 1
| +-- [load children]
| +-- Sub comment 2
| +-- [load children]
| +-- Sub comment 3
| +-- [load children]
| +-- [load more childs for Comment 1]
+-- Comment 2
| +-- Sub comment 1
| +-- Sub comment 2
| +-- [load children]
| +-- Sub comment 3
| +-- [load more childs for Comment 2]
+-- Comment 3
| +-- Sub comment 1
| +-- [load children]
| +-- Sub comment 2
| +-- Sub comment 3
| +-- [load more childs for Comment 3]
[load more root comments]
I'm not sure if my description is clear or if linked reddit story is a clear example of what i mean.
How i'm handling it so far is initially fetching just the paginated root comments (comments. find_all_by_generation(0)) and loading their children (recursively) only if user clicks "Load replies" button on the frontend side.
That endpoint might return the comments as a flat collection, they don't need to be nested (i'm using parent_id to show them in a proper thread on frontend side)
Thanks in advance for any tips, if something is unclear, i'm gonna try to explain it further.
The text was updated successfully, but these errors were encountered:
Hello!
First of all, thank you for this great piece of software.
I'm creating a website with threaded comments functionality - working kind of like reddit. There is a post, post can have many comments and each comment can have many sub-comments.
closure_tree
makes working with such setup a breeze but things gets complicated when i want to expose my comments through REST API in a consumer-friendly way.My ultimate goal is to make it work like reddit comments works: initial story page load shows paginated list of root comments and their paginated children comments up to x depth (i'm not sure what's the exact depth but, say, 3). Example: https://www.reddit.com/r/ColorizedHistory/comments/8ojpss/queen_victoria_and_her_family_including_king/
I'm not able to reverse-engineer it as it seems that the initial comments list is rendered server-side but i'm gonna try to explain what such endpoint should return:
I'm not sure if my description is clear or if linked reddit story is a clear example of what i mean.
How i'm handling it so far is initially fetching just the paginated root comments (
comments. find_all_by_generation(0)
) and loading their children (recursively) only if user clicks "Load replies" button on the frontend side.That endpoint might return the comments as a flat collection, they don't need to be nested (i'm using
parent_id
to show them in a proper thread on frontend side)Thanks in advance for any tips, if something is unclear, i'm gonna try to explain it further.
The text was updated successfully, but these errors were encountered: