WIP better author handling.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// but some rules are too "annoying" or are not applicable for your case.)
|
||||
#![allow(clippy::wildcard_imports)]
|
||||
|
||||
use itertools::Itertools;
|
||||
use log::{debug, error, info, warn, Level};
|
||||
use notmuch::{Content, Part, SearchSummary, Thread, ThreadNode, ThreadSet};
|
||||
use seed::{prelude::*, *};
|
||||
@@ -267,8 +268,27 @@ fn set_title(title: &str) {
|
||||
seed::document().set_title(&format!("lb: {}", title));
|
||||
}
|
||||
|
||||
fn tags_chiclet(tags: &[String]) -> Node<Msg> {
|
||||
empty![]
|
||||
fn tags_chiclet(tags: &[String]) -> impl Iterator<Item = Node<Msg>> + '_ {
|
||||
tags.iter().map(|tag| match tag.as_str() {
|
||||
"attachment" => span![C!["tag"], "📎"],
|
||||
"replied" => span![C!["tag"], i![C!["fa-solid", "fa-reply"]]],
|
||||
_ => span![C!["tag"], tag],
|
||||
})
|
||||
}
|
||||
|
||||
fn pretty_authors(authors: &str) -> impl Iterator<Item = Node<Msg>> + '_ {
|
||||
let authors = authors.split(',');
|
||||
|
||||
authors
|
||||
.map(|author| {
|
||||
span![
|
||||
attrs! {
|
||||
At::Title => author},
|
||||
author.split_whitespace().nth(0)
|
||||
]
|
||||
})
|
||||
.into()
|
||||
.iterleave(itertools::repeat_n(",", authors.len()).map(|c| span![c]))
|
||||
}
|
||||
|
||||
fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg> {
|
||||
@@ -282,9 +302,9 @@ fn view_search_results(query: &str, search_results: &SearchSummary) -> Node<Msg>
|
||||
tr![
|
||||
td![
|
||||
C!["from"],
|
||||
//pretty_authors(&r.authors),
|
||||
&r.authors,
|
||||
IF!(r.total>1 => small![" ", r.total.to_string()]),
|
||||
IF!(r.tags.contains(&"attachment".to_string()) => "📎"),
|
||||
],
|
||||
td![C!["subject"], tags_chiclet(&r.tags), &r.subject],
|
||||
td![C!["date"], &r.date_relative],
|
||||
@@ -391,6 +411,7 @@ fn view_header(query: &str) -> Node<Msg> {
|
||||
|
||||
// `view` describes what to display.
|
||||
fn view(model: &Model) -> Node<Msg> {
|
||||
info!("view called");
|
||||
let content = match &model.context {
|
||||
Context::None => div![h1!["Loading"]],
|
||||
Context::Thread(thread_set) => view_thread(thread_set),
|
||||
|
||||
Reference in New Issue
Block a user