Comments, Discussions, and Recursion

Posted by Denny at 14:12 on Thu, 20 Feb 2020

Screenshot of comment thread, showing two levels of reply indentingToday I merged the first chunk of work on discussions / comment threads.

As in the original ShinyCMS, the comment threads (and sub-threads) are fully nested, so you can easily tell what's a second/third/etc level reply and see who is talking to who.

To get the nested comments to display with the correct indentation at each level requires recursion*. Understanding recursion is nearing the limit of how clever I get on a good day, so in the past I have occasionally regretted writing this feature when I've had to work on it on a less good day ;) Not as much as I'd regret having written a comments feature with Facebook-style single-level nesting though :)

*  Or at least, that's how I did it. From what I've read, for any problem where recursion is the most 'obvious' solution, there's almost always a solution that doesn't use recursion too ... but when I've read up on those I've generally found them even more confusing than recursion is :D

Tags: clever discussions nesting recursion comments

« MJML, comment notifications, and reCAPTCHA for registrations Moar demo data »


No comments found