summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-07-09 09:18:23 -0600
committerColin Reeder <colin@vpzom.click>2020-07-09 09:18:23 -0600
commit5e302b81be25f00635cea654f2c0ee9bac97a8ae (patch)
tree34ac93f9e23f209824b643f2b5af9f69889cfe6f
parentd8bcc4040d025b6efb633d117d4db0eee58308c6 (diff)
Show "View More Comments" when tree hits limit (#13)
-rw-r--r--src/components/mod.rs16
-rw-r--r--src/resp_types.rs1
2 files changed, 13 insertions, 4 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 545ab56..cd348ba 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -54,8 +54,7 @@ pub fn Comment<'comment, 'base_data>(
</div>
{
- match &comment.replies {
- Some(replies) => {
+ if let Some(replies) = &comment.replies {
Some(render::rsx! {
<ul>
{
@@ -68,8 +67,17 @@ pub fn Comment<'comment, 'base_data>(
}
</ul>
})
- },
- None => None,
+ } else {
+ None
+ }
+ }
+ {
+ if comment.replies.is_none() && comment.has_replies {
+ Some(render::rsx! {
+ <ul><li><a href={format!("/comments/{}", comment.id)}>{"-> View More Comments"}</a></li></ul>
+ })
+ } else {
+ None
}
}
</li>
diff --git a/src/resp_types.rs b/src/resp_types.rs
index 53e0935..dfe7619 100644
--- a/src/resp_types.rs
+++ b/src/resp_types.rs
@@ -34,6 +34,7 @@ pub struct RespPostCommentInfo<'a> {
pub your_vote: Option<Empty>,
#[serde(borrow)]
pub replies: Option<Vec<RespPostCommentInfo<'a>>>,
+ pub has_replies: bool,
}
#[derive(Deserialize, Debug)]