mirror of
https://github.com/redlib-org/redlib.git
synced 2025-04-02 04:37:35 +03:00
fix(posts): shorten sort call
This commit is contained in:
parent
4ccf7290f6
commit
07b24c9858
1 changed files with 1 additions and 9 deletions
10
src/utils.rs
10
src/utils.rs
|
@ -424,15 +424,7 @@ impl Post {
|
|||
});
|
||||
}
|
||||
posts.sort_by(|a, b| b.created_ts.cmp(&a.created_ts));
|
||||
posts.sort_by(|a, b| {
|
||||
if a.flags.stickied && !b.flags.stickied {
|
||||
return std::cmp::Ordering::Less;
|
||||
}
|
||||
if !a.flags.stickied && b.flags.stickied {
|
||||
return std::cmp::Ordering::Greater;
|
||||
}
|
||||
std::cmp::Ordering::Equal
|
||||
});
|
||||
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…
Add table
Add a link
Reference in a new issue