Compare commits
61 Commits
letterbox-
...
letterbox-
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b6cb6ec6e | |||
| 0cba3a624c | |||
| 73433711ca | |||
| 965afa6871 | |||
| e70dbaf917 | |||
| 6b4ce11743 | |||
| d1980a55a7 | |||
| 8b78b39d4c | |||
| ae17651eb5 | |||
| 22fd8409f6 | |||
| d0a4ba417f | |||
| 7b09b098a4 | |||
| bd4c10a8fb | |||
| ed3c5f152e | |||
| 63232d1e92 | |||
| 4a3eba80d5 | |||
| 71d3745342 | |||
| 5fdc98633d | |||
| 57877f268d | |||
| 871a93d58f | |||
| 4b7cbd4f9b | |||
| aa2a9815df | |||
| 2e5b18a008 | |||
| d0a38114cc | |||
| ccc1d516c7 | |||
| 246b710fdd | |||
| 1a21c9fa8e | |||
| 9fd912b1d4 | |||
| 9ded32f97b | |||
| 10aac046bc | |||
| f4527baf89 | |||
| 11ec5bf747 | |||
| 6a53679755 | |||
| 7bedec0692 | |||
| 78feb95811 | |||
| 3aad2bb80e | |||
| 0df8de3661 | |||
| 83ecc73fbd | |||
| c10313cd12 | |||
| 4c98bcd9cb | |||
| 004de235a8 | |||
| 90dbeb6f20 | |||
| 9aa298febe | |||
| 5a13a497dc | |||
| 37711e14dd | |||
| e89fd28707 | |||
| 7a91ee2f49 | |||
| 4b76ea5392 | |||
| d2a81b7bd9 | |||
| 9dd39509b5 | |||
| d605bcfe7a | |||
| 73abdb535a | |||
| ab9506c4f6 | |||
| 994a629401 | |||
| 00c55160a7 | |||
| e3c6edb894 | |||
| 4574c016cd | |||
| ca6c19f4c8 | |||
| 0f51f6e71f | |||
| 4bd672bf94 | |||
| 136fd77f3b |
@@ -49,3 +49,19 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
- run: cargo build
|
||||
|
||||
udeps:
|
||||
name: Disallow unused dependencies
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
|
||||
- name: Run cargo-udeps
|
||||
uses: aig787/cargo-udeps-action@v1
|
||||
with:
|
||||
version: 'latest'
|
||||
args: '--all-targets'
|
||||
|
||||
|
||||
7294
Cargo.lock
generated
7294
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -1,8 +1,15 @@
|
||||
[workspace]
|
||||
resolver = "2"
|
||||
#default-members = ["server"]
|
||||
members = ["notmuch", "procmail2notmuch", "shared"]
|
||||
#members = ["web", "server", "notmuch", "procmail2notmuch", "shared"]
|
||||
default-members = ["server"]
|
||||
members = ["web", "server", "notmuch", "procmail2notmuch", "shared"]
|
||||
|
||||
[workspace.package]
|
||||
authors = ["Bill Thiede <git@xinu.tv>"]
|
||||
edition = "2021"
|
||||
license = "UNLICENSED"
|
||||
publish = ["xinu"]
|
||||
version = "0.8.3"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
||||
16
Justfile
Normal file
16
Justfile
Normal file
@@ -0,0 +1,16 @@
|
||||
default:
|
||||
@echo "Run: just patch|minor|major"
|
||||
|
||||
major: (_release "major")
|
||||
minor: (_release "minor")
|
||||
patch: (_release "patch")
|
||||
|
||||
sqlx-prepare:
|
||||
cd server; cargo sqlx prepare && git add .sqlx; git commit -m "cargo sqlx prepare" .sqlx || true
|
||||
|
||||
pull:
|
||||
git pull
|
||||
|
||||
|
||||
_release level: pull sqlx-prepare
|
||||
cargo-release release -x {{ level }} --workspace --no-confirm --registry=xinu
|
||||
@@ -1,16 +1,18 @@
|
||||
[package]
|
||||
name = "letterbox-notmuch"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
exclude = ["/testdata"]
|
||||
description = "Wrapper for calling notmuch cli"
|
||||
license = "UNLICENSED"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
publish = ["xinu"]
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
|
||||
[dependencies]
|
||||
log = "0.4.14"
|
||||
mailparse = "0.16.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0", features = ["unbounded_depth"] }
|
||||
thiserror = "2.0.0"
|
||||
|
||||
@@ -207,6 +207,7 @@
|
||||
//! ```
|
||||
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
ffi::OsStr,
|
||||
io::{self},
|
||||
path::{Path, PathBuf},
|
||||
@@ -459,6 +460,8 @@ pub enum NotmuchError {
|
||||
StringUtf8Error(#[from] std::string::FromUtf8Error),
|
||||
#[error("failed to parse str as int")]
|
||||
ParseIntError(#[from] std::num::ParseIntError),
|
||||
#[error("failed to parse mail: {0}")]
|
||||
MailParseError(#[from] mailparse::MailParseError),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -605,6 +608,59 @@ impl Notmuch {
|
||||
Ok(serde_json::from_slice(&res)?)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
pub fn unread_recipients(&self) -> Result<HashMap<String, usize>, NotmuchError> {
|
||||
let slice = self.run_notmuch([
|
||||
"show",
|
||||
"--include-html=false",
|
||||
"--entire-thread=false",
|
||||
"--body=false",
|
||||
"--format=json",
|
||||
// Arbitrary limit to prevent too much work
|
||||
"--limit=1000",
|
||||
"is:unread",
|
||||
])?;
|
||||
// Notmuch returns JSON with invalid unicode. So we lossy convert it to a string here and
|
||||
// use that for parsing in rust.
|
||||
let s = String::from_utf8_lossy(&slice);
|
||||
let mut deserializer = serde_json::Deserializer::from_str(&s);
|
||||
deserializer.disable_recursion_limit();
|
||||
let ts: ThreadSet = serde::de::Deserialize::deserialize(&mut deserializer)?;
|
||||
deserializer.end()?;
|
||||
let mut r = HashMap::new();
|
||||
for t in ts.0 {
|
||||
for tn in t.0 {
|
||||
let Some(msg) = tn.0 else {
|
||||
continue;
|
||||
};
|
||||
let mut addrs = vec![];
|
||||
let hdr = msg.headers.to;
|
||||
if let Some(to) = hdr {
|
||||
addrs.push(to);
|
||||
};
|
||||
let hdr = msg.headers.cc;
|
||||
if let Some(cc) = hdr {
|
||||
addrs.push(cc);
|
||||
};
|
||||
for recipient in addrs {
|
||||
mailparse::addrparse(&recipient)?
|
||||
.into_inner()
|
||||
.iter()
|
||||
.for_each(|a| {
|
||||
let mailparse::MailAddr::Single(si) = a else {
|
||||
return;
|
||||
};
|
||||
let addr = &si.addr;
|
||||
if addr == "couchmoney@gmail.com" || addr.ends_with("@xinu.tv") {
|
||||
*r.entry(addr.clone()).or_default() += 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
fn run_notmuch<I, S>(&self, args: I) -> Result<Vec<u8>, NotmuchError>
|
||||
where
|
||||
I: IntoIterator<Item = S>,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
[package]
|
||||
name = "letterbox-procmail2notmuch"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Tool for generating notmuch rules from procmail"
|
||||
license = "UNLICENSED"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
publish = ["xinu"]
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
[package]
|
||||
name = "letterbox-server"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
default-run = "letterbox-server"
|
||||
description = "Backend for letterbox"
|
||||
license = "UNLICENSED"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
publish = ["xinu"]
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
@@ -46,9 +47,9 @@ url = "2.5.2"
|
||||
urlencoding = "2.1.3"
|
||||
#xtracing = { path = "../../xtracing" }
|
||||
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
|
||||
xtracing = { version = "0.2.0", registry = "xinu" }
|
||||
letterbox-notmuch = { version = "0.1.0", registry = "xinu" }
|
||||
letterbox-shared = { version = "0.1.0", registry = "xinu" }
|
||||
xtracing = { version = "0.3.0", registry = "xinu" }
|
||||
letterbox-notmuch = { version = "0.8.3", path = "../notmuch", registry = "xinu" }
|
||||
letterbox-shared = { version = "0.8.3", path = "../shared", registry = "xinu" }
|
||||
|
||||
[build-dependencies]
|
||||
build-info-build = "0.0.39"
|
||||
|
||||
@@ -341,7 +341,7 @@ impl<'c> Transformer for SlurpContents<'c> {
|
||||
"/* chrome-default.css */\n",
|
||||
include_str!("chrome-default.css"),
|
||||
"\n/* vars.css */\n",
|
||||
include_str!("../../web/static/vars.css"),
|
||||
include_str!("../static/vars.css"),
|
||||
//"\n/* Xinu Specific overrides */\n",
|
||||
//include_str!("custom.css"),
|
||||
);
|
||||
@@ -793,7 +793,17 @@ impl FromStr for Query {
|
||||
if word == "is:unread" {
|
||||
unread_only = true
|
||||
} else if word.starts_with("tag:") {
|
||||
tags.push(word["tag:".len()..].to_string());
|
||||
let t = &word["tag:".len()..];
|
||||
// Per-address emails are faked as `tag:@<domain>/<username>`, rewrite to `to:` form
|
||||
if t.starts_with('@') && t.contains('.') {
|
||||
let t = match t.split_once('/') {
|
||||
None => format!("to:{t}"),
|
||||
Some((domain, user)) => format!("to:{user}{domain}"),
|
||||
};
|
||||
remainder.push(t);
|
||||
} else {
|
||||
tags.push(t.to_string());
|
||||
};
|
||||
|
||||
/*
|
||||
} else if word.starts_with("tag:") {
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::File,
|
||||
hash::{DefaultHasher, Hash, Hasher},
|
||||
time::Instant,
|
||||
};
|
||||
use std::{collections::HashMap, fs::File};
|
||||
|
||||
use letterbox_notmuch::Notmuch;
|
||||
use letterbox_shared::compute_color;
|
||||
use log::{error, info, warn};
|
||||
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
||||
use memmap::MmapOptions;
|
||||
@@ -107,7 +103,6 @@ pub async fn search(
|
||||
|
||||
#[instrument(name="nm::tags", skip_all, fields(needs_unread=needs_unread))]
|
||||
pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
||||
let now = Instant::now();
|
||||
let unread_msg_cnt: HashMap<String, usize> = if needs_unread {
|
||||
// 10000 is an arbitrary number, if there's more than 10k unread messages, we'll
|
||||
// get an inaccurate count.
|
||||
@@ -123,13 +118,11 @@ pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
||||
} else {
|
||||
HashMap::new()
|
||||
};
|
||||
let tags = nm
|
||||
let tags: Vec<_> = nm
|
||||
.tags()?
|
||||
.into_iter()
|
||||
.map(|tag| {
|
||||
let mut hasher = DefaultHasher::new();
|
||||
tag.hash(&mut hasher);
|
||||
let hex = format!("#{:06x}", hasher.finish() % (1 << 24));
|
||||
let hex = compute_color(&tag);
|
||||
let unread = if needs_unread {
|
||||
*unread_msg_cnt.get(&tag).unwrap_or(&0)
|
||||
} else {
|
||||
@@ -142,8 +135,24 @@ pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
||||
unread,
|
||||
}
|
||||
})
|
||||
.chain(
|
||||
nm.unread_recipients()?
|
||||
.into_iter()
|
||||
.filter_map(|(name, unread)| {
|
||||
let Some(idx) = name.find('@') else {
|
||||
return None;
|
||||
};
|
||||
let name = format!("{}/{}", &name[idx..], &name[..idx]);
|
||||
let bg_color = compute_color(&name);
|
||||
Some(Tag {
|
||||
name,
|
||||
fg_color: "white".to_string(),
|
||||
bg_color,
|
||||
unread,
|
||||
})
|
||||
}),
|
||||
)
|
||||
.collect();
|
||||
info!("Fetching tags took {} seconds", now.elapsed().as_secs_f32());
|
||||
Ok(tags)
|
||||
}
|
||||
|
||||
|
||||
42
server/static/vars.css
Normal file
42
server/static/vars.css
Normal file
@@ -0,0 +1,42 @@
|
||||
:root {
|
||||
--active-brightness: 0.85;
|
||||
--border-radius: 5px;
|
||||
--box-shadow: 2px 2px 10px;
|
||||
--color-accent: #118bee15;
|
||||
--color-bg: #fff;
|
||||
--color-bg-secondary: #e9e9e9;
|
||||
--color-link: #118bee;
|
||||
--color-secondary: #920de9;
|
||||
--color-secondary-accent: #920de90b;
|
||||
--color-shadow: #f4f4f4;
|
||||
--color-table: #118bee;
|
||||
--color-text: #000;
|
||||
--color-text-secondary: #999;
|
||||
--color-scrollbar: #cacae8;
|
||||
--font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
||||
--hover-brightness: 1.2;
|
||||
--justify-important: center;
|
||||
--justify-normal: left;
|
||||
--line-height: 1.5;
|
||||
/*
|
||||
--width-card: 285px;
|
||||
--width-card-medium: 460px;
|
||||
--width-card-wide: 800px;
|
||||
*/
|
||||
--width-content: 1080px;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root[color-mode="user"] {
|
||||
--color-accent: #0097fc4f;
|
||||
--color-bg: #333;
|
||||
--color-bg-secondary: #555;
|
||||
--color-link: #0097fc;
|
||||
--color-secondary: #e20de9;
|
||||
--color-secondary-accent: #e20de94f;
|
||||
--color-shadow: #bbbbbb20;
|
||||
--color-table: #0097fc;
|
||||
--color-text: #f7f7f7;
|
||||
--color-text-secondary: #aaa;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
[package]
|
||||
name = "letterbox-shared"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
description = "Shared module for letterbox"
|
||||
license = "UNLICENSED"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
publish = ["xinu"]
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
build-info = "0.0.39"
|
||||
letterbox-notmuch = { version = "0.1.0", registry = "xinu" }
|
||||
letterbox-notmuch = { version = "0.8.3", path = "../notmuch", registry = "xinu" }
|
||||
serde = { version = "1.0.147", features = ["derive"] }
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
[package]
|
||||
version = "0.1.0"
|
||||
name = "letterbox-web"
|
||||
authors = ["Bill Thiede <git@xinu.tv>"]
|
||||
edition = "2021"
|
||||
description = "Web frontend for letterbox"
|
||||
license = "UNLICENSED"
|
||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||
publish = ["xinu"]
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
publish.workspace = true
|
||||
repository.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
build-info-build = "0.0.39"
|
||||
@@ -26,7 +26,6 @@ serde_json = { version = "1.0.93", features = ["unbounded_depth"] }
|
||||
chrono = "0.4.31"
|
||||
graphql_client = "0.14.0"
|
||||
thiserror = "2.0.0"
|
||||
seed_hooks = { git = "https://github.com/wathiede/styles_hooks", package = "seed_hooks", branch = "main" }
|
||||
gloo-net = { version = "0.6.0", features = ["json", "serde_json"] }
|
||||
human_format = "1.1.0"
|
||||
build-info = "0.0.39"
|
||||
@@ -34,8 +33,9 @@ wasm-bindgen = "=0.2.100"
|
||||
uuid = { version = "1.13.1", features = [
|
||||
"js",
|
||||
] } # direct dep to set js feature, prevents Rng issues
|
||||
letterbox-shared = { version = "0.1.0", registry = "xinu" }
|
||||
letterbox-notmuch = { version = "0.1.0", path = "../notmuch", registry = "xinu" }
|
||||
letterbox-shared = { version = "0.8.3", path = "../shared", registry = "xinu" }
|
||||
letterbox-notmuch = { version = "0.8.3", path = "../notmuch", registry = "xinu" }
|
||||
seed_hooks = { version = "0.4.0", registry = "xinu" }
|
||||
|
||||
[package.metadata.wasm-pack.profile.release]
|
||||
wasm-opt = ['-Os']
|
||||
|
||||
@@ -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};
|
||||
@@ -6,8 +6,8 @@ use itertools::Itertools;
|
||||
use letterbox_shared::compute_color;
|
||||
use log::{debug, error, info};
|
||||
use seed::{prelude::*, *};
|
||||
use seed_hooks::{state_access::CloneState, topo, use_state};
|
||||
use web_sys::HtmlElement;
|
||||
use seed_hooks::{state_access::CloneState, topo, use_state, StateAccessEventHandlers};
|
||||
use web_sys::{HtmlElement, HtmlInputElement};
|
||||
|
||||
use crate::{
|
||||
api::urls,
|
||||
@@ -60,6 +60,7 @@ mod tw_classes {
|
||||
"accent-green-600",
|
||||
"appearance-none",
|
||||
"checked:appearance-auto",
|
||||
"indeterminate:appearance-auto",
|
||||
"rounded",
|
||||
"border",
|
||||
"border-neutral-500",
|
||||
@@ -95,7 +96,6 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
"lg:flex-nowrap",
|
||||
"w-full"
|
||||
],
|
||||
reading_progress(model.read_completion_ratio),
|
||||
div![
|
||||
C!["w-full", "lg:w-48", "flex-none", "flex", "flex-col"],
|
||||
tags(model),
|
||||
@@ -109,7 +109,8 @@ pub fn view(model: &Model) -> Node<Msg> {
|
||||
view_header(&model.query, &model.refreshing_state, true),
|
||||
content,
|
||||
view_header(&model.query, &model.refreshing_state, false),
|
||||
]
|
||||
],
|
||||
reading_progress(model.read_completion_ratio),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -135,7 +136,6 @@ fn search_results(
|
||||
tags.remove(idx);
|
||||
};
|
||||
let is_unread = unread_idx.is_some();
|
||||
// TODO: add check-all button, and tristate indicator
|
||||
div![
|
||||
C![
|
||||
"flex",
|
||||
@@ -189,11 +189,12 @@ fn search_results(
|
||||
]
|
||||
});
|
||||
let show_bulk_edit = !selected_threads.is_empty();
|
||||
let all_selected = selected_threads.len() == results.len();
|
||||
div![
|
||||
C!["flex", "flex-col", "flex-auto", "p-4"],
|
||||
search_toolbar(count, pager, show_bulk_edit),
|
||||
search_toolbar(count, pager, show_bulk_edit, all_selected),
|
||||
div![rows],
|
||||
search_toolbar(count, pager, show_bulk_edit),
|
||||
search_toolbar(count, pager, show_bulk_edit, all_selected),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -310,47 +311,71 @@ fn human_age(timestamp: i64) -> String {
|
||||
datetime
|
||||
}
|
||||
|
||||
#[topo::nested]
|
||||
fn search_toolbar(
|
||||
count: usize,
|
||||
pager: &FrontPageQuerySearchPageInfo,
|
||||
show_bulk_edit: bool,
|
||||
all_selected: bool,
|
||||
) -> Node<Msg> {
|
||||
let indeterminate = show_bulk_edit && !all_selected;
|
||||
let tristate_el: ElRef<HtmlInputElement> = use_state(|| Default::default()).get();
|
||||
let tri = el_ref(&tristate_el);
|
||||
if let Some(tri) = tri.get() {
|
||||
info!(
|
||||
"setting tristate to {indeterminate}, current {}",
|
||||
tri.indeterminate()
|
||||
);
|
||||
tri.set_indeterminate(indeterminate);
|
||||
}
|
||||
nav![
|
||||
C!["p-4", "flex", "w-full", "justify-between"],
|
||||
C!["py-4", "flex", "w-full", "justify-between"],
|
||||
div![
|
||||
C!["gap-2", "flex"],
|
||||
IF!(show_bulk_edit =>
|
||||
C!["gap-2", "flex", IF!(!show_bulk_edit => "invisible")],
|
||||
div![
|
||||
button![
|
||||
C![&tw_classes::BUTTON, "rounded-r-none"],
|
||||
attrs!{At::Title => "Mark as read"},
|
||||
span![i![C!["far", "fa-envelope-open"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Read"],
|
||||
ev(Ev::Click, |_| Msg::SelectionMarkAsRead)
|
||||
],
|
||||
button![
|
||||
C![&tw_classes::BUTTON, "rounded-l-none"],
|
||||
attrs!{At::Title => "Mark as unread"},
|
||||
span![i![C!["far", "fa-envelope"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Unread"],
|
||||
ev(Ev::Click, |_| Msg::SelectionMarkAsUnread)
|
||||
]
|
||||
]),
|
||||
IF!(show_bulk_edit =>
|
||||
C!["flex", "items-center", "mr-4"],
|
||||
input![
|
||||
tri,
|
||||
C![&tw_classes::CHECKBOX],
|
||||
attrs! {
|
||||
At::Type=>"checkbox",
|
||||
At::Checked=>all_selected,
|
||||
}
|
||||
],
|
||||
ev(Ev::Input, move |_| {
|
||||
if all_selected {
|
||||
Msg::SelectionSetNone
|
||||
} else {
|
||||
Msg::SelectionSetAll
|
||||
}
|
||||
}),
|
||||
],
|
||||
div![
|
||||
button![
|
||||
C![&tw_classes::BUTTON, "text-red-500"],
|
||||
attrs!{At::Title => "Mark as spam"},
|
||||
span![i![C!["far", "fa-hand"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Spam"],
|
||||
ev(Ev::Click, |_|
|
||||
Msg::MultiMsg(vec![
|
||||
Msg::SelectionAddTag("Spam".to_string()),
|
||||
Msg::SelectionMarkAsRead
|
||||
])
|
||||
)
|
||||
button![
|
||||
C![&tw_classes::BUTTON, "rounded-r-none"],
|
||||
attrs! {At::Title => "Mark as read"},
|
||||
span![i![C!["far", "fa-envelope-open"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Read"],
|
||||
ev(Ev::Click, |_| Msg::SelectionMarkAsRead)
|
||||
],
|
||||
button![
|
||||
C![&tw_classes::BUTTON, "rounded-l-none"],
|
||||
attrs! {At::Title => "Mark as unread"},
|
||||
span![i![C!["far", "fa-envelope"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Unread"],
|
||||
ev(Ev::Click, |_| Msg::SelectionMarkAsUnread)
|
||||
]
|
||||
]),
|
||||
],
|
||||
div![button![
|
||||
C![&tw_classes::BUTTON, "text-red-500"],
|
||||
attrs! {At::Title => "Mark as spam"},
|
||||
span![i![C!["far", "fa-hand"]]],
|
||||
span![C!["pl-2", "hidden", "md:inline"], "Spam"],
|
||||
ev(Ev::Click, |_| Msg::MultiMsg(vec![
|
||||
Msg::SelectionAddTag("Spam".to_string()),
|
||||
Msg::SelectionMarkAsRead
|
||||
]))
|
||||
]],
|
||||
],
|
||||
div![
|
||||
C!["flex", "gap-2", "items-center"],
|
||||
@@ -857,9 +882,7 @@ fn view_content_tree(content_tree: &str) -> Node<Msg> {
|
||||
}
|
||||
]],
|
||||
" Debug",
|
||||
ev(Ev::Click, move |_| {
|
||||
debug_open.set(!debug_open.get());
|
||||
})
|
||||
debug_open.on_click(|d| *d = !*d)
|
||||
],
|
||||
IF!(debug_open.get() =>
|
||||
pre![C!["NOTPORTED","content-tree"], content_tree]),
|
||||
@@ -879,6 +902,7 @@ fn view_header(
|
||||
false
|
||||
};
|
||||
let query = Url::decode_uri_component(query).unwrap_or("".to_string());
|
||||
|
||||
nav![
|
||||
C!["flex", "px-4", "pt-4", "overflow-hidden"],
|
||||
a![
|
||||
@@ -1008,11 +1032,23 @@ 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)
|
||||
};
|
||||
return r;
|
||||
});
|
||||
let tags_open = use_state(|| false);
|
||||
let force_tags_open = unread.is_empty();
|
||||
aside![
|
||||
@@ -1030,9 +1066,7 @@ pub fn tags(model: &Model) -> Node<Msg> {
|
||||
"fa-angle-down"
|
||||
}
|
||||
]]),
|
||||
ev(Ev::Click, move |_| {
|
||||
tags_open.set(!tags_open.get());
|
||||
})
|
||||
tags_open.on_click(|t| *t = !*t)
|
||||
],
|
||||
div![
|
||||
IF!(force_tags_open||tags_open.get() => model.tags.as_ref().map(|tags| view_tags(tags.iter(),false))),
|
||||
|
||||
Reference in New Issue
Block a user