~vpzom/hitide

19a16864e5a0a31de923d13050d4a5b43da69d45 — Colin Reeder 14 days ago 73d29fc
Show comment count in post lists
4 files changed, 46 insertions(+), 27 deletions(-)

M res/lang/en.ftl
M res/lang/eo.ftl
M src/components/mod.rs
M src/resp_types.rs
M res/lang/en.ftl => res/lang/en.ftl +1 -0
@@ 61,6 61,7 @@ or_start = Or
password_prompt = Password:
post_approve = Approve
post_approve_undo = Remove from Community
post_comments_count = { $count } comments
post_delete_question = Delete this post?
post_delete_title = Delete Post
post_likes_nothing = Looks like nobody has liked this post yet.

M res/lang/eo.ftl => res/lang/eo.ftl +1 -0
@@ 61,6 61,7 @@ or_start = Aŭ
password_prompt = Pasvorto:
post_approve = Aprobi
post_approve_undo = Forpreni el komunumo
post_comments_count = { $count } komentoj
post_delete_question = Ĉu vi volas forigi ĉi tiun poŝton?
post_delete_title = Forigi Poŝton
post_likes_nothing = Ŝajnas, ke neniu ankoraŭ ŝatis ĉi tion poŝton.

M src/components/mod.rs => src/components/mod.rs +26 -22
@@ 299,11 299,11 @@ pub fn PostItem<'a>(
) {
    render::rsx! {
        <li>
            <a href={format!("/posts/{}", post.as_ref().id)}>
                {post.as_ref().title.as_ref()}
            <a href={format!("/posts/{}", post.as_ref().as_ref().id)}>
                {post.as_ref().as_ref().title.as_ref()}
            </a>
            {
                if let Some(href) = &post.href {
                if let Some(href) = &post.as_ref().href {
                    Some(render::rsx! {
                        <>
                            {" "}


@@ 315,27 315,31 @@ pub fn PostItem<'a>(
                }
            }
            <br />
            {lang.tr("submitted", None)}
            {
                if no_user {
                    None
                } else {
                    Some(render::rsx! {
                        <>
                            {" "}{lang.tr("by", None)}{" "}<UserLink user={post.author.as_ref()} />
                        </>
                    })
            <small>
                {lang.tr("submitted", None)}
                {
                    if no_user {
                        None
                    } else {
                        Some(render::rsx! {
                            <>
                                {" "}{lang.tr("by", None)}{" "}<UserLink user={post.as_ref().author.as_ref()} />
                            </>
                        })
                    }
                }
            }
            {
                if !in_community {
                    Some(render::rsx! {
                        <>{" "}{lang.tr("to", None)}{" "}<CommunityLink community={&post.community} /></>
                    })
                } else {
                    None
                {
                    if !in_community {
                        Some(render::rsx! {
                            <>{" "}{lang.tr("to", None)}{" "}<CommunityLink community={&post.as_ref().community} /></>
                        })
                    } else {
                        None
                    }
                }
            }
                {" | "}
                {lang.tr("post_comments_count", Some(&fluent::fluent_args!["count" => post.replies_count_total])).into_owned()}
            </small>
        </li>
    }
}

M src/resp_types.rs => src/resp_types.rs +18 -5
@@ 17,7 17,7 @@ pub struct RespMinimalPostInfo<'a> {
}

#[derive(Deserialize, Debug)]
pub struct RespPostListPost<'a> {
pub struct RespSomePostInfo<'a> {
    #[serde(flatten)]
    pub base: RespMinimalPostInfo<'a>,
    pub href: Option<Cow<'a, str>>,


@@ 28,13 28,26 @@ pub struct RespPostListPost<'a> {
    pub community: RespMinimalCommunityInfo<'a>,
}

impl<'a> AsRef<RespMinimalPostInfo<'a>> for RespPostListPost<'a> {
impl<'a> AsRef<RespMinimalPostInfo<'a>> for RespSomePostInfo<'a> {
    fn as_ref(&self) -> &RespMinimalPostInfo<'a> {
        &self.base
    }
}

#[derive(Deserialize, Debug)]
pub struct RespPostListPost<'a> {
    #[serde(flatten, borrow)]
    pub base: RespSomePostInfo<'a>,
    pub replies_count_total: i64,
}

impl<'a> AsRef<RespSomePostInfo<'a>> for RespPostListPost<'a> {
    fn as_ref(&self) -> &RespSomePostInfo<'a> {
        &self.base
    }
}

#[derive(Deserialize, Debug)]
#[serde(tag = "type")]
pub enum RespThingInfo<'a> {
    #[serde(rename = "post")]


@@ 114,7 127,7 @@ impl<'a> AsRef<RespPostCommentInfo<'a>> for RespCommentInfo<'a> {
#[derive(Deserialize, Debug)]
pub struct RespPostInfo<'a> {
    #[serde(flatten, borrow)]
    pub base: RespPostListPost<'a>,
    pub base: RespSomePostInfo<'a>,

    pub content_text: Option<Cow<'a, str>>,
    pub content_html: Option<Cow<'a, str>>,


@@ 126,8 139,8 @@ pub struct RespPostInfo<'a> {
    pub your_vote: Option<Empty>,
}

impl<'a> AsRef<RespPostListPost<'a>> for RespPostInfo<'a> {
    fn as_ref(&self) -> &RespPostListPost<'a> {
impl<'a> AsRef<RespSomePostInfo<'a>> for RespPostInfo<'a> {
    fn as_ref(&self) -> &RespSomePostInfo<'a> {
        &self.base
    }
}