This implements the `context` query parameter without querying the
Pushshift comment endpoint with `ids`, which until recently only worked
for certain time periods. Now that this is fixed for all comments after
Oct/23/2017 21:55, it makes sense to use a more simple solution instead.
Comments in the time ranges below need a workaround which slows down
Pushshift queries, but it's required to retrieve them correctly
* Sep/1/2017 0:00 - Sep/30/2017 23:59:59 UTC
* Feb/1/2018 0:00 - Mar/31/2018 23:59:59 UTC
There were two bugs when a permalinked comment was missing from
Pushshift, but available via Reddit:
* the links below the comment (`permalink reddit reveddit`) were
often broken due to calling `redditIdsToPushshift()` twice
* if removed or deleted, it wasn't counted or colored correctly
* make the post placeholder bigger to minimize the layout changes
as the post loads
* correctly add link clicks to the location history if the current
location differs from the link target
Removed/deleted self-posts are still fetched from Pushshift to get
the selftext, however there's no value in fetching link-posts.
Also:
* Don't display '[deleted]' if no selftext was deleted.
* Add key attributes to the post <div> so that React recreates
it instead of mutating it after the Post loads. This prevents
transitioning the background color (from the dark/light mode css).
Visiting a permalink (from an internal or external link) now scrolls to
just past the post, and both parent and permalinks scroll smoothly where
appropriate; it makes sense for internal permalinks to immediately jump.
* Only redirect Reddit post links to Unddit if it's likely to work.
* Use React <Link>s instead of <a>s if the post link matches the
post itself. This avoids an unnecessary page reload if clicked.
* Relative links in comments still don't work well...
Beforehand, visiting a permalink would cause Unddit to begin loading
from the Post's first comment. If the max-to-download setting was too
small, and the permalinked comment wasn't yet encountered, no comment
tree would be displayed.
Now, only comments that occur at the same time as the permalinked
comment or later (chronologically) are downloaded.
This also adds a Parent link to each comment. When viewing a permalinked
comment, clicking the top-level Parent link will download only new
comments between the parent and child comments. Likewise, clicking the
'view rest of comments' link will only download new comments from the
first comment up until the previously viewed comment.
In general, Unddit will not re-download comments that it knows it has
previously downloaded, nor download more than max-to-download comments
per link clicked. This can leave 'gaps' in the list of downloaded
comments. If the 'load more comments' link is clicked, Unddit will only
download comments that can fill such gaps between the currently-linked
permalink (or if not viewing one, the first comment) and the last, up to
the max-to-download setting.
maxComments is now only the user-preferred setting, and has nothing to
do with displayed state. loadingMoreComments is used to trigger loading
more comments, and temporarily contains the desired comment count to
load. This should make future changes easier. Also fix two minor bugs:
* the 'Reload' was sometimes hidden after clicking 'load more comments'
* 'loaded x more comments' incorrectly appeared after clicking 'Reload'
Beforehand, Pushshift comments were all downloaded first, then they were
processed, then all Reddit comments were downloaded, then processed.
Now, as each batch of Pushshift comments completes, it is processed
asynchronously, and Reddit comments are downloaded & processed as soon
as enough comment IDs have been batched for submission. This minimizes
the amount of time spent in the 'Comparing comments to Reddit API'
phase. It also spaces out Reddit API requests for better netiquette.