show the count of 'more replies'. (#740)

Co-authored-by: Daniel Valentine <daniel@vielle.ws>
Co-authored-by: Matthew Esposito <matt@matthew.science>
This commit is contained in:
mikupls 2023-03-09 05:30:41 +01:00 committed by GitHub
parent bf19ff513f
commit 01f9907aaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -107,6 +107,13 @@ fn parse_comments(json: &serde_json::Value, post_link: &str, post_author: &str,
let score = data["score"].as_i64().unwrap_or(0);
// The JSON API only provides comments up to some threshold.
// Further comments have to be loaded by subsequent requests.
// The "kind" value will be "more" and the "count"
// shows how many more (sub-)comments exist in the respective nesting level.
// Note that in certain (seemingly random) cases, the count is simply wrong.
let more_count = data["count"].as_i64().unwrap_or_default();
// If this comment contains replies, handle those too
let replies: Vec<Comment> = if data["replies"].is_object() {
parse_comments(&data["replies"], post_link, post_author, highlighted_comment, filters, req)
@ -177,6 +184,7 @@ fn parse_comments(json: &serde_json::Value, post_link: &str, post_author: &str,
awards,
collapsed,
is_filtered,
more_count,
prefs: Preferences::new(req),
}
})

View File

@ -377,6 +377,7 @@ pub struct Comment {
pub awards: Awards,
pub collapsed: bool,
pub is_filtered: bool,
pub more_count: i64,
pub prefs: Preferences,
}

View File

@ -1,7 +1,7 @@
{% import "utils.html" as utils %}
{% if kind == "more" && parent_kind == "t1" %}
<a class="deeper_replies" href="{{ post_link }}{{ parent_id }}">&rarr; More replies</a>
<a class="deeper_replies" href="{{ post_link }}{{ parent_id }}">&rarr; More replies ({{ more_count }})</a>
{% else if kind == "t1" %}
<div id="{{ id }}" class="comment">
<div class="comment_left">