fix(posts): shorten sort call

This commit is contained in:
Matthew Esposito 2024-06-29 13:24:09 -04:00
parent 4ccf7290f6
commit 07b24c9858

View file

@ -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()))
}
}