WIP better author handling.
This commit is contained in:
parent
e5a27f82f9
commit
25541bc1ca
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -975,6 +975,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"console_log",
|
"console_log",
|
||||||
|
"itertools",
|
||||||
"log 0.4.17",
|
"log 0.4.17",
|
||||||
"notmuch",
|
"notmuch",
|
||||||
"seed",
|
"seed",
|
||||||
|
|||||||
@ -22,6 +22,7 @@ seed = "0.9.2"
|
|||||||
console_log = {git = "http://git-private.h.xinu.tv/wathiede/console_log.git"}
|
console_log = {git = "http://git-private.h.xinu.tv/wathiede/console_log.git"}
|
||||||
serde = { version = "1.0.147", features = ["derive"] }
|
serde = { version = "1.0.147", features = ["derive"] }
|
||||||
notmuch = {path = "../notmuch"}
|
notmuch = {path = "../notmuch"}
|
||||||
|
itertools = "0.10.5"
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.release]
|
[package.metadata.wasm-pack.profile.release]
|
||||||
wasm-opt = ['-Os']
|
wasm-opt = ['-Os']
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
<link rel="modulepreload" href="/pkg/package.js" as="script" type="text/javascript">
|
<link rel="modulepreload" href="/pkg/package.js" as="script" type="text/javascript">
|
||||||
<link rel="preload" href="/pkg/package_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous">
|
<link rel="preload" href="/pkg/package_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||||
<style>
|
<style>
|
||||||
.message {
|
.message {
|
||||||
padding-left: 0.5em;
|
padding-left: 0.5em;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
// but some rules are too "annoying" or are not applicable for your case.)
|
// but some rules are too "annoying" or are not applicable for your case.)
|
||||||
#![allow(clippy::wildcard_imports)]
|
#![allow(clippy::wildcard_imports)]
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
use log::{debug, error, info, warn, Level};
|
use log::{debug, error, info, warn, Level};
|
||||||
use notmuch::{Content, Part, SearchSummary, Thread, ThreadNode, ThreadSet};
|
use notmuch::{Content, Part, SearchSummary, Thread, ThreadNode, ThreadSet};
|
||||||
use seed::{prelude::*, *};
|
use seed::{prelude::*, *};
|
||||||
@ -267,8 +268,27 @@ fn set_title(title: &str) {
|
|||||||
seed::document().set_title(&format!("lb: {}", title));
|
seed::document().set_title(&format!("lb: {}", title));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tags_chiclet(tags: &[String]) -> Node<Msg> {
|
fn tags_chiclet(tags: &[String]) -> impl Iterator<Item = Node<Msg>> + '_ {
|
||||||
empty![]
|
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> {
|
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![
|
tr![
|
||||||
td![
|
td![
|
||||||
C!["from"],
|
C!["from"],
|
||||||
|
//pretty_authors(&r.authors),
|
||||||
&r.authors,
|
&r.authors,
|
||||||
IF!(r.total>1 => small![" ", r.total.to_string()]),
|
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!["subject"], tags_chiclet(&r.tags), &r.subject],
|
||||||
td![C!["date"], &r.date_relative],
|
td![C!["date"], &r.date_relative],
|
||||||
@ -391,6 +411,7 @@ fn view_header(query: &str) -> Node<Msg> {
|
|||||||
|
|
||||||
// `view` describes what to display.
|
// `view` describes what to display.
|
||||||
fn view(model: &Model) -> Node<Msg> {
|
fn view(model: &Model) -> Node<Msg> {
|
||||||
|
info!("view called");
|
||||||
let content = match &model.context {
|
let content = match &model.context {
|
||||||
Context::None => div![h1!["Loading"]],
|
Context::None => div![h1!["Loading"]],
|
||||||
Context::Thread(thread_set) => view_thread(thread_set),
|
Context::Thread(thread_set) => view_thread(thread_set),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user