Compare commits

..

3 Commits

3 changed files with 26 additions and 9 deletions

1
dev.sh
View File

@ -1,3 +1,4 @@
cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"
tmux new-session -d -s letterbox-dev tmux new-session -d -s letterbox-dev
tmux rename-window web tmux rename-window web
tmux send-keys "cd web; trunk serve --release --address 0.0.0.0 --port 6758 --proxy-backend http://localhost:9345/ --proxy-rewrite=/api/ -w ../shared -w ../notmuch -w ./" C-m tmux send-keys "cd web; trunk serve --release --address 0.0.0.0 --port 6758 --proxy-backend http://localhost:9345/ --proxy-rewrite=/api/ -w ../shared -w ../notmuch -w ./" C-m

View File

@ -5,6 +5,7 @@ enum MatchType {
From, From,
Sender, Sender,
To, To,
Cc,
Subject, Subject,
List, List,
DeliveredTo, DeliveredTo,
@ -81,6 +82,11 @@ impl FromStr for Match {
match_type: MatchType::From, match_type: MatchType::From,
needle: cleanup_match(FROM, needle), needle: cleanup_match(FROM, needle),
}); });
} else if needle.starts_with(CC) {
return Ok(Match {
match_type: MatchType::Cc,
needle: cleanup_match(CC, needle),
});
} else if needle.starts_with(TOCC) { } else if needle.starts_with(TOCC) {
return Ok(Match { return Ok(Match {
match_type: MatchType::To, match_type: MatchType::To,
@ -88,7 +94,7 @@ impl FromStr for Match {
}); });
} else if needle.starts_with(SENDER) { } else if needle.starts_with(SENDER) {
return Ok(Match { return Ok(Match {
match_type: MatchType::From, match_type: MatchType::Sender,
needle: cleanup_match(SENDER, needle), needle: cleanup_match(SENDER, needle),
}); });
} else if needle.starts_with(SUBJECT) { } else if needle.starts_with(SUBJECT) {
@ -140,7 +146,6 @@ impl FromStr for Match {
needle: cleanup_match("", &needle), needle: cleanup_match("", &needle),
}); });
} }
Ok(Match::default())
} }
} }
@ -161,6 +166,7 @@ fn notmuch_from_rules<W: Write>(mut w: W, rules: &[Rule]) -> anyhow::Result<()>
// TODO(wathiede): something more specific? // TODO(wathiede): something more specific?
MatchType::Sender => "from:", MatchType::Sender => "from:",
MatchType::To => "to:", MatchType::To => "to:",
MatchType::Cc => "to:",
MatchType::Subject => "subject:", MatchType::Subject => "subject:",
MatchType::List => "List-ID:", MatchType::List => "List-ID:",
MatchType::Body => "", MatchType::Body => "",

View File

@ -8,7 +8,7 @@ use std::{
}; };
use itertools::Itertools; use itertools::Itertools;
use log::{debug, error, info, warn, Level}; use log::{debug, error, info, Level};
use notmuch::{Content, Part, Thread, ThreadNode, ThreadSet}; use notmuch::{Content, Part, Thread, ThreadNode, ThreadSet};
use seed::{prelude::*, *}; use seed::{prelude::*, *};
use serde::de::Deserialize; use serde::de::Deserialize;
@ -512,7 +512,8 @@ fn view_mobile_search_results(query: &str, search_results: &shared::SearchResult
div![ div![
h1!["Search results"], h1!["Search results"],
view_search_pager(first, summaries.len(), search_results.total), view_search_pager(first, summaries.len(), search_results.total),
rows rows,
view_search_pager(first, summaries.len(), search_results.total)
] ]
} }
@ -564,26 +565,35 @@ fn view_search_results(query: &str, search_results: &shared::SearchResult) -> No
th![C!["date"], "Date"] th![C!["date"], "Date"]
]], ]],
tbody![rows] tbody![rows]
] ],
view_search_pager(first, summaries.len(), search_results.total)
] ]
} }
fn view_search_pager(page: usize, count: usize, total: usize) -> Node<Msg> { fn view_search_pager(start: usize, count: usize, total: usize) -> Node<Msg> {
let is_first = start <= 0;
let is_last = (start + SEARCH_RESULTS_PER_PAGE) >= total;
nav![ nav![
C!["pagination"], C!["pagination"],
a![ a![
C!["pagination-previous", "button"], C![
"pagination-previous",
"button",
IF!(is_first => "is-static"),
IF!(is_first => "is-info"),
],
"<", "<",
ev(Ev::Click, |_| Msg::PreviousPage) ev(Ev::Click, |_| Msg::PreviousPage)
], ],
a![ a![
C!["pagination-next", "button"], C!["pagination-next", "button", IF!(is_last => "is-static")],
IF!(is_last => attrs!{ At::Disabled=>true }),
">", ">",
ev(Ev::Click, |_| Msg::NextPage) ev(Ev::Click, |_| Msg::NextPage)
], ],
ul![ ul![
C!["pagination-list"], C!["pagination-list"],
li![format!("{} - {} of {}", page, page + count, total)], li![format!("{} - {} of {}", start, start + count, total)],
], ],
] ]
} }