Compare commits
54 Commits
letterbox-
...
letterbox-
| Author | SHA1 | Date | |
|---|---|---|---|
| 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/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
- run: cargo build
|
- 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'
|
||||||
|
|
||||||
|
|||||||
7100
Cargo.lock
generated
7100
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -1,8 +1,15 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
#default-members = ["server"]
|
default-members = ["server"]
|
||||||
members = ["notmuch", "procmail2notmuch", "shared"]
|
members = ["web", "server", "notmuch", "procmail2notmuch", "shared"]
|
||||||
#members = ["web", "server", "notmuch", "procmail2notmuch", "shared"]
|
|
||||||
|
[workspace.package]
|
||||||
|
authors = ["Bill Thiede <git@xinu.tv>"]
|
||||||
|
edition = "2021"
|
||||||
|
license = "UNLICENSED"
|
||||||
|
publish = ["xinu"]
|
||||||
|
version = "0.8.2"
|
||||||
|
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
opt-level = 1
|
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]
|
[package]
|
||||||
name = "letterbox-notmuch"
|
name = "letterbox-notmuch"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
exclude = ["/testdata"]
|
exclude = ["/testdata"]
|
||||||
description = "Wrapper for calling notmuch cli"
|
description = "Wrapper for calling notmuch cli"
|
||||||
license = "UNLICENSED"
|
authors.workspace = true
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
edition.workspace = true
|
||||||
publish = ["xinu"]
|
license.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
|
mailparse = "0.16.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = { version = "1.0", features = ["unbounded_depth"] }
|
serde_json = { version = "1.0", features = ["unbounded_depth"] }
|
||||||
thiserror = "2.0.0"
|
thiserror = "2.0.0"
|
||||||
|
|||||||
@@ -207,6 +207,7 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
io::{self},
|
io::{self},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@@ -459,6 +460,8 @@ pub enum NotmuchError {
|
|||||||
StringUtf8Error(#[from] std::string::FromUtf8Error),
|
StringUtf8Error(#[from] std::string::FromUtf8Error),
|
||||||
#[error("failed to parse str as int")]
|
#[error("failed to parse str as int")]
|
||||||
ParseIntError(#[from] std::num::ParseIntError),
|
ParseIntError(#[from] std::num::ParseIntError),
|
||||||
|
#[error("failed to parse mail: {0}")]
|
||||||
|
MailParseError(#[from] mailparse::MailParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -605,6 +608,59 @@ impl Notmuch {
|
|||||||
Ok(serde_json::from_slice(&res)?)
|
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>
|
fn run_notmuch<I, S>(&self, args: I) -> Result<Vec<u8>, NotmuchError>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = S>,
|
I: IntoIterator<Item = S>,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "letterbox-procmail2notmuch"
|
name = "letterbox-procmail2notmuch"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
description = "Tool for generating notmuch rules from procmail"
|
description = "Tool for generating notmuch rules from procmail"
|
||||||
license = "UNLICENSED"
|
authors.workspace = true
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
edition.workspace = true
|
||||||
publish = ["xinu"]
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "letterbox-server"
|
name = "letterbox-server"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
default-run = "letterbox-server"
|
default-run = "letterbox-server"
|
||||||
description = "Backend for letterbox"
|
description = "Backend for letterbox"
|
||||||
license = "UNLICENSED"
|
authors.workspace = true
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
edition.workspace = true
|
||||||
publish = ["xinu"]
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@@ -47,8 +48,8 @@ urlencoding = "2.1.3"
|
|||||||
#xtracing = { path = "../../xtracing" }
|
#xtracing = { path = "../../xtracing" }
|
||||||
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
|
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
|
||||||
xtracing = { version = "0.2.0", registry = "xinu" }
|
xtracing = { version = "0.2.0", registry = "xinu" }
|
||||||
letterbox-notmuch = { version = "0.1.0", registry = "xinu" }
|
letterbox-notmuch = { version = "0.8.2", path = "../notmuch", registry = "xinu" }
|
||||||
letterbox-shared = { version = "0.1.0", registry = "xinu" }
|
letterbox-shared = { version = "0.8.2", path = "../shared", registry = "xinu" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
build-info-build = "0.0.39"
|
build-info-build = "0.0.39"
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ impl<'c> Transformer for SlurpContents<'c> {
|
|||||||
"/* chrome-default.css */\n",
|
"/* chrome-default.css */\n",
|
||||||
include_str!("chrome-default.css"),
|
include_str!("chrome-default.css"),
|
||||||
"\n/* vars.css */\n",
|
"\n/* vars.css */\n",
|
||||||
include_str!("../../web/static/vars.css"),
|
include_str!("../static/vars.css"),
|
||||||
//"\n/* Xinu Specific overrides */\n",
|
//"\n/* Xinu Specific overrides */\n",
|
||||||
//include_str!("custom.css"),
|
//include_str!("custom.css"),
|
||||||
);
|
);
|
||||||
@@ -793,7 +793,17 @@ impl FromStr for Query {
|
|||||||
if word == "is:unread" {
|
if word == "is:unread" {
|
||||||
unread_only = true
|
unread_only = true
|
||||||
} else if word.starts_with("tag:") {
|
} 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:") {
|
} else if word.starts_with("tag:") {
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
use std::{
|
use std::{collections::HashMap, fs::File};
|
||||||
collections::HashMap,
|
|
||||||
fs::File,
|
|
||||||
hash::{DefaultHasher, Hash, Hasher},
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
|
|
||||||
use letterbox_notmuch::Notmuch;
|
use letterbox_notmuch::Notmuch;
|
||||||
|
use letterbox_shared::compute_color;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
use mailparse::{parse_content_type, parse_mail, MailHeader, MailHeaderMap, ParsedMail};
|
||||||
use memmap::MmapOptions;
|
use memmap::MmapOptions;
|
||||||
@@ -107,7 +103,6 @@ pub async fn search(
|
|||||||
|
|
||||||
#[instrument(name="nm::tags", skip_all, fields(needs_unread=needs_unread))]
|
#[instrument(name="nm::tags", skip_all, fields(needs_unread=needs_unread))]
|
||||||
pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
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 {
|
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
|
// 10000 is an arbitrary number, if there's more than 10k unread messages, we'll
|
||||||
// get an inaccurate count.
|
// get an inaccurate count.
|
||||||
@@ -123,13 +118,11 @@ pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
|||||||
} else {
|
} else {
|
||||||
HashMap::new()
|
HashMap::new()
|
||||||
};
|
};
|
||||||
let tags = nm
|
let tags: Vec<_> = nm
|
||||||
.tags()?
|
.tags()?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|tag| {
|
.map(|tag| {
|
||||||
let mut hasher = DefaultHasher::new();
|
let hex = compute_color(&tag);
|
||||||
tag.hash(&mut hasher);
|
|
||||||
let hex = format!("#{:06x}", hasher.finish() % (1 << 24));
|
|
||||||
let unread = if needs_unread {
|
let unread = if needs_unread {
|
||||||
*unread_msg_cnt.get(&tag).unwrap_or(&0)
|
*unread_msg_cnt.get(&tag).unwrap_or(&0)
|
||||||
} else {
|
} else {
|
||||||
@@ -142,8 +135,24 @@ pub fn tags(nm: &Notmuch, needs_unread: bool) -> Result<Vec<Tag>, ServerError> {
|
|||||||
unread,
|
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();
|
.collect();
|
||||||
info!("Fetching tags took {} seconds", now.elapsed().as_secs_f32());
|
|
||||||
Ok(tags)
|
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]
|
[package]
|
||||||
name = "letterbox-shared"
|
name = "letterbox-shared"
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2021"
|
|
||||||
description = "Shared module for letterbox"
|
description = "Shared module for letterbox"
|
||||||
license = "UNLICENSED"
|
authors.workspace = true
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
edition.workspace = true
|
||||||
publish = ["xinu"]
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
build-info = "0.0.39"
|
build-info = "0.0.39"
|
||||||
letterbox-notmuch = { version = "0.1.0", registry = "xinu" }
|
letterbox-notmuch = { version = "0.8.2", path = "../notmuch", registry = "xinu" }
|
||||||
serde = { version = "1.0.147", features = ["derive"] }
|
serde = { version = "1.0.147", features = ["derive"] }
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
[package]
|
[package]
|
||||||
version = "0.1.0"
|
|
||||||
name = "letterbox-web"
|
name = "letterbox-web"
|
||||||
authors = ["Bill Thiede <git@xinu.tv>"]
|
|
||||||
edition = "2021"
|
|
||||||
description = "Web frontend for letterbox"
|
description = "Web frontend for letterbox"
|
||||||
license = "UNLICENSED"
|
authors.workspace = true
|
||||||
repository = "https://git.z.xinu.tv/wathiede/letterbox"
|
edition.workspace = true
|
||||||
publish = ["xinu"]
|
license.workspace = true
|
||||||
|
publish.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
version.workspace = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
build-info-build = "0.0.39"
|
build-info-build = "0.0.39"
|
||||||
@@ -26,7 +26,6 @@ serde_json = { version = "1.0.93", features = ["unbounded_depth"] }
|
|||||||
chrono = "0.4.31"
|
chrono = "0.4.31"
|
||||||
graphql_client = "0.14.0"
|
graphql_client = "0.14.0"
|
||||||
thiserror = "2.0.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"] }
|
gloo-net = { version = "0.6.0", features = ["json", "serde_json"] }
|
||||||
human_format = "1.1.0"
|
human_format = "1.1.0"
|
||||||
build-info = "0.0.39"
|
build-info = "0.0.39"
|
||||||
@@ -34,8 +33,9 @@ wasm-bindgen = "=0.2.100"
|
|||||||
uuid = { version = "1.13.1", features = [
|
uuid = { version = "1.13.1", features = [
|
||||||
"js",
|
"js",
|
||||||
] } # direct dep to set js feature, prevents Rng issues
|
] } # direct dep to set js feature, prevents Rng issues
|
||||||
letterbox-shared = { version = "0.1.0", registry = "xinu" }
|
letterbox-shared = { version = "0.8.2", path = "../shared", registry = "xinu" }
|
||||||
letterbox-notmuch = { version = "0.1.0", path = "../notmuch", registry = "xinu" }
|
letterbox-notmuch = { version = "0.8.2", path = "../notmuch", registry = "xinu" }
|
||||||
|
seed_hooks = { version = "0.1.13", registry = "xinu" }
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.release]
|
[package.metadata.wasm-pack.profile.release]
|
||||||
wasm-opt = ['-Os']
|
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 chrono::{DateTime, Datelike, Duration, Local, Utc};
|
||||||
use human_format::{Formatter, Scales};
|
use human_format::{Formatter, Scales};
|
||||||
@@ -6,7 +6,7 @@ use itertools::Itertools;
|
|||||||
use letterbox_shared::compute_color;
|
use letterbox_shared::compute_color;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use seed::{prelude::*, *};
|
use seed::{prelude::*, *};
|
||||||
use seed_hooks::{state_access::CloneState, topo, use_state};
|
use seed_hooks::{state_access::CloneState, topo, use_state, StateAccessEventHandlers};
|
||||||
use web_sys::HtmlElement;
|
use web_sys::HtmlElement;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -95,7 +95,6 @@ pub fn view(model: &Model) -> Node<Msg> {
|
|||||||
"lg:flex-nowrap",
|
"lg:flex-nowrap",
|
||||||
"w-full"
|
"w-full"
|
||||||
],
|
],
|
||||||
reading_progress(model.read_completion_ratio),
|
|
||||||
div![
|
div![
|
||||||
C!["w-full", "lg:w-48", "flex-none", "flex", "flex-col"],
|
C!["w-full", "lg:w-48", "flex-none", "flex", "flex-col"],
|
||||||
tags(model),
|
tags(model),
|
||||||
@@ -109,7 +108,8 @@ pub fn view(model: &Model) -> Node<Msg> {
|
|||||||
view_header(&model.query, &model.refreshing_state, true),
|
view_header(&model.query, &model.refreshing_state, true),
|
||||||
content,
|
content,
|
||||||
view_header(&model.query, &model.refreshing_state, false),
|
view_header(&model.query, &model.refreshing_state, false),
|
||||||
]
|
],
|
||||||
|
reading_progress(model.read_completion_ratio),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -857,9 +857,7 @@ fn view_content_tree(content_tree: &str) -> Node<Msg> {
|
|||||||
}
|
}
|
||||||
]],
|
]],
|
||||||
" Debug",
|
" Debug",
|
||||||
ev(Ev::Click, move |_| {
|
debug_open.on_click(|d| *d = !*d)
|
||||||
debug_open.set(!debug_open.get());
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
IF!(debug_open.get() =>
|
IF!(debug_open.get() =>
|
||||||
pre![C!["NOTPORTED","content-tree"], content_tree]),
|
pre![C!["NOTPORTED","content-tree"], content_tree]),
|
||||||
@@ -1008,11 +1006,26 @@ pub fn tags(model: &Model) -> Node<Msg> {
|
|||||||
}
|
}
|
||||||
tag_els
|
tag_els
|
||||||
}
|
}
|
||||||
let unread = model
|
let mut unread = model
|
||||||
.tags
|
.tags
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|tags| tags.iter().filter(|t| t.unread > 0).collect())
|
.map(|tags| tags.iter().filter(|t| t.unread > 0).collect())
|
||||||
.unwrap_or(Vec::new());
|
.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 tags_open = use_state(|| false);
|
||||||
let force_tags_open = unread.is_empty();
|
let force_tags_open = unread.is_empty();
|
||||||
aside![
|
aside![
|
||||||
@@ -1030,9 +1043,7 @@ pub fn tags(model: &Model) -> Node<Msg> {
|
|||||||
"fa-angle-down"
|
"fa-angle-down"
|
||||||
}
|
}
|
||||||
]]),
|
]]),
|
||||||
ev(Ev::Click, move |_| {
|
tags_open.on_click(|t| *t = !*t)
|
||||||
tags_open.set(!tags_open.get());
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
div![
|
div![
|
||||||
IF!(force_tags_open||tags_open.get() => model.tags.as_ref().map(|tags| view_tags(tags.iter(),false))),
|
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