Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the process of dealing with MoreComments objects. #70

Open
avinashbot opened this issue Oct 4, 2017 · 1 comment
Open

Simplify the process of dealing with MoreComments objects. #70

avinashbot opened this issue Oct 4, 2017 · 1 comment

Comments

@avinashbot
Copy link
Owner

avinashbot commented Oct 4, 2017

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 expands MoreComments as you iterate through it and caches the resulting data.

Architecture

Initialization

  1. A CommentListing is initialized by the Submission to represent the comments.
  2. Every subsequent comment also initializes the CommentListing with a reference to the main Submission.

Expanding

  1. 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.
  2. The MoreComments object uses this to check where to push expanded comments to.
  3. This also helps users fetch all comments in a submission.
@avinashbot avinashbot changed the title Create the CommentListing type. Simplify the process of dealing with MoreComments objects. Oct 8, 2017
@Brotakuu
Copy link

This feature would be extremely useful. How are you currently constructing the hierarchy when expanding MoreComments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants