consolidate shared helpers into utils crate

This commit is contained in:
2026-10-03 11:00:59 +07:00
parent 24070cc2cd
commit d00ee33eab
16 changed files with 89 additions and 177 deletions
+2 -11
View File
@@ -188,8 +188,8 @@ where
.map(|root| {
let mut events = groups.remove(&root).unwrap_or_default();
let mut own_events = own_groups.remove(&root).unwrap_or_default();
sort_newest_first(&mut events);
sort_newest_first(&mut own_events);
utils::sort_newest_first(&mut events);
utils::sort_newest_first(&mut own_events);
let root_event = lookup(root);
@@ -218,15 +218,6 @@ where
items
}
/// Sort thread events newest first, ties broken by id.
fn sort_newest_first(events: &mut [Event]) {
events.sort_by(|a, b| {
b.created_at
.cmp(&a.created_at)
.then_with(|| b.id.to_hex().cmp(&a.id.to_hex()))
});
}
/// Read and archive state of the inbox, a high-water-mark model.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct InboxReadState {