Add automatic per-email address unread folders

This commit is contained in:
2025-02-22 10:54:20 -08:00
parent 2e5b18a008
commit aa2a9815df
6 changed files with 148 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
use std::collections::HashSet;
use std::{cmp::Ordering, collections::HashSet};
use chrono::{DateTime, Datelike, Duration, Local, Utc};
use human_format::{Formatter, Scales};
@@ -1006,11 +1006,26 @@ pub fn tags(model: &Model) -> Node<Msg> {
}
tag_els
}
let unread = model
let mut unread = model
.tags
.as_ref()
.map(|tags| tags.iter().filter(|t| t.unread > 0).collect())
.unwrap_or(Vec::new());
unread.sort_by(|a, b| {
let r = if a.name.starts_with('@') && b.name.starts_with('@') {
a.name.cmp(&b.name)
} else if a.name.starts_with('@') {
Ordering::Less
} else if b.name.starts_with('@') {
Ordering::Greater
} else {
a.name.cmp(&b.name)
};
if a.name.starts_with('@') || b.name.starts_with('@') {
info!("a {} < b {} = {r:?}", a.name, b.name,);
}
return r;
});
let tags_open = use_state(|| false);
let force_tags_open = unread.is_empty();
aside![