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
When iterating through comments in a submission, users have to deal with a MoreComments, an object that represents comments that need to be expanded manually. Expanding them is also a pain because the object returns a flat listing of comments, forcing me to manually reconstruct the hierarchy locally.
The Solution
A custom CommentListing type that expands MoreComments as you iterate through it and caches the resulting data.
Architecture
Initialization
A CommentListing is initialized by the Submission to represent the comments.
Every subsequent comment also initializes the CommentListing with a reference to the main Submission.
Expanding
If it hasn't been done before, a method is called on the Submission to traverse the comment tree and store references to all subcomments by their id. All unexpanded MoreComments are also stored separately.
The MoreComments object uses this to check where to push expanded comments to.
This also helps users fetch all comments in a submission.
The text was updated successfully, but these errors were encountered:
The Problem
When iterating through comments in a submission, users have to deal with a
MoreComments
, an object that represents comments that need to be expanded manually. Expanding them is also a pain because the object returns a flat listing of comments, forcing me to manually reconstruct the hierarchy locally.The Solution
A custom
CommentListing
type that expandsMoreComments
as you iterate through it and caches the resulting data.Architecture
Initialization
Expanding
The text was updated successfully, but these errors were encountered: