How is it possible to build a list of comments that are threaded or indented andor have lines to show connection? Something like this:
Hi, itâs kinda tricky and I donât think that my solution is optimized but it works.
Data Architecture:
- Conversation (Thread): contains a list of comments
- Comment:
- content
- parents (list of all parentâs comment)
- conversation (id of the tread)
Front:
Some Nested RG
- 1st level RG of threads
- 2nd level RG of comments based on the list of the current thread comments
- 3rd level RG of spacers that add a horizontal spacer based on the number of parents for the current comment
Here some screenshots to help:
trying to wrap my head around your solution which is pretty dope. is your setup scalable insofar as having a near endless stream of threads // levels? Or is it preset to where thereâs a max of three levels?
I wonder what the lift is on bubbleâs end for rendering so many repeating groups and if itâs even possible to make this more efficient.
i currently have two levels of comments, but thatâs it. if Instagram can get away with it, so can I, however, from the technical perspective, I wish I at least had the option.
Oh man, whyâd I never think of an RG for the spacing? Iâve always resorted to custom CSS that changes the indentation width.
The main snag that is even harder to resolve is how you order the comments (as in Bubble, we canât have infinitely nested RGs e.g an RG of replies, then another RG of replies only if there are children replies).
So, @eliot1, as Iâm sure youâve already noticed, if someone replies to âI am the second commentâ now, the reply would likely appear after âResponse to first commentâ as youâve ordered them by date, when it should appear under âAnd I am the last oneâ. I donât have a solution for this either by the way.
Thanks. I am not sure what to do when there are more than three sub comments but that should be ok for now.
I think I should be able to do it with conversation and then message with some sort of numbering system and/or getting a pre or post fix and changing margins if there is a pre or post fix.
The solution is good. I implemented something similar a while ago.
Instead of using Parent Comments, I used child comments. And added a field âorder (number)â So the 2nd level RG contained all the children comments: sorted by order.
The order were maintained in the way that in your current example it will look like this:
This is the first comment (order 1)
âI am the second comment (Order 2)
âAnd I am the last one (Order 3)
âResponse to the first comment (Order 2)
Did you see what I was playing around with over here?
I think something similar could be leveraged here where the ânumberâ of spacers introduced is tied to @animisha45 concept here:
This is a fun one
We once developed a Task Module for a client who needed infinite subtask recursion. The underlying challenge and approach is essentially the same as a comment thread, and the data structure can be the same.
@eliot1 the spacing RG is a cool concept. That approach is generally a good start but sadly that wonât cover all bases. As George says, there is no way to manage the order of the list of comments, and you can only really reply to the last comment and append the created comment to the list. Even if you get past that, storing and maintaining a long list is not great for scalability and reliability; if multiple users add a comment at the same time their operations will overwrite each-other and one or more comments will be lost.
I like storing a number field on the Comment called âdepthâ which represents how far nested the comment/subtask is. This is great for backend organisation but also for frontend formatting - itâs very useful for conditionals. Itâs also best to use a list of children rather than a list of parents.
You have to use custom states and looping for this sort of problem, no way around it.
Loop through items to initialise the complete list of comments while maintaining the correct order.
Something along the lines of âList of Items: items until current cell index: merge with: current commentâs subcomments: merged with: List of Itemsâ.
Thank you all @georgecollier @animisha45 @nico.dicagno for your help
It haunted me so I tried something else.
I used both parent and child fields to help me construct an order string like this:
1
1.1
1.1.1
1.1.2
1.1.2.1
1.2
1.2.1
âŠ
Then I just sort the RG comments with this order.
Seems too simple⊠Am I missing something ?
Yeah, thatâs a creative solution and would probably work - so long as each ânestâ can have up to 9 comments. Because once you have:
1.8.1
1.9.1
1.10.1
1.11.1
the alphabetical sorting will get screwed up.
You could in theory assign a sort order number to each comment whenever a new comment is created, but thatâs of course really inefficient.
Yep thatâs the problem⊠Actually you can âextendâ this technique by adding one or several leading 0 to the index when < to 10, 100, 1000, âŠ
Like this:
001.008.001
001.009.001
001.010.001
But itâs not very elegant and still limited
I like your solution a lot. Sure it has limitations, but so would every solution for this problem. Pretty neat.