fix(posts): fix sort call on new (#171)
This commit is contained in:
parent
366bc17f97
commit
67a890cab3
@ -145,6 +145,10 @@ pub async fn community(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||
let (_, all_posts_filtered) = filter_posts(&mut posts, &filters);
|
||||
let no_posts = posts.is_empty();
|
||||
let all_posts_hidden_nsfw = !no_posts && (posts.iter().all(|p| p.flags.nsfw) && setting(&req, "show_nsfw") != "on");
|
||||
if sort == "new" {
|
||||
posts.sort_by(|a, b| b.created_ts.cmp(&a.created_ts));
|
||||
posts.sort_by(|a, b| b.flags.stickied.cmp(&a.flags.stickied));
|
||||
}
|
||||
Ok(template(&SubredditTemplate {
|
||||
sub,
|
||||
posts,
|
||||
|
@ -425,8 +425,6 @@ impl Post {
|
||||
ws_url: val(post, "websocket_url"),
|
||||
});
|
||||
}
|
||||
posts.sort_by(|a, b| b.created_ts.cmp(&a.created_ts));
|
||||
posts.sort_by(|a, b| b.flags.stickied.cmp(&a.flags.stickied));
|
||||
Ok((posts, res["data"]["after"].as_str().unwrap_or_default().to_string()))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user