~vpzom/hitide

63e299675b68a818adcab5f4acf3dbe4919afcf3 — Colin Reeder 18 days ago f3f9004
Add handling for sticky posts in post lists
4 files changed, 9 insertions(+), 2 deletions(-)

M res/main.css
M src/components/mod.rs
M src/resp_types.rs
M src/routes/communities.rs
M res/main.css => res/main.css +5 -0
@@ 130,6 130,11 @@ body {
	padding-left: 0;
}

.sticky > .titleLine > a {
	color: #558B2F;
	font-weight: bold;
}

.titleLine {
	white-space: nowrap;
	display: flex;

M src/components/mod.rs => src/components/mod.rs +1 -1
@@ 345,7 345,7 @@ pub fn PostItem<'a>(
    lang: &'a crate::Translator,
) {
    render::rsx! {
        <li>
        <li class={if post.sticky { "sticky" } else { "" }}>
            <div class={"titleLine"}>
                <a href={format!("/posts/{}", post.as_ref().as_ref().id)}>
                    {post.as_ref().as_ref().title.as_ref()}

M src/resp_types.rs => src/resp_types.rs +1 -0
@@ 39,6 39,7 @@ pub struct RespPostListPost<'a> {
    #[serde(flatten, borrow)]
    pub base: RespSomePostInfo<'a>,
    pub replies_count_total: i64,
    pub sticky: bool,
}

impl<'a> AsRef<RespSomePostInfo<'a>> for RespPostListPost<'a> {

M src/routes/communities.rs => src/routes/communities.rs +2 -1
@@ 146,10 146,11 @@ async fn page_community(
        ctx.http_client
            .request(for_client(
                hyper::Request::get(format!(
                    "{}/api/unstable/communities/{}/posts?sort={}",
                    "{}/api/unstable/communities/{}/posts?sort={}&sort_sticky={}",
                    ctx.backend_host,
                    community_id,
                    query.sort.as_str(),
                    query.sort == crate::SortType::Hot,
                ))
                .body(Default::default())?,
                req.headers(),