Compare commits

...

32 Commits

Author SHA1 Message Date
32d2ffeb3d chore: Release
All checks were successful
Continuous integration / Test Suite (push) Successful in 44s
Continuous integration / Trunk (push) Successful in 41s
Continuous integration / Rustfmt (push) Successful in 32s
Continuous integration / Check (push) Successful in 2m37s
Continuous integration / build (push) Successful in 56s
Continuous integration / Disallow unused dependencies (push) Successful in 2m36s
2025-02-27 15:16:09 -08:00
d41946e0a5 web: change style for mark read catchup button 2025-02-27 15:15:49 -08:00
61402858f4 web: add TODO 2025-02-27 15:15:42 -08:00
17de318645 chore: Release
All checks were successful
Continuous integration / Test Suite (push) Successful in 47s
Continuous integration / Check (push) Successful in 2m0s
Continuous integration / Trunk (push) Successful in 39s
Continuous integration / build (push) Successful in 52s
Continuous integration / Rustfmt (push) Successful in 1m6s
Continuous integration / Disallow unused dependencies (push) Successful in 56s
2025-02-26 15:43:34 -08:00
3aa0144e8d web: try setting history.scroll_restoration to manual to impove inter-page flow 2025-02-26 15:43:18 -08:00
f9eafff4c7 web: add "go home" button to catchup view 2025-02-26 15:43:18 -08:00
4c6d67901d fix(deps): update rust crate uuid to v1.15.1
All checks were successful
Continuous integration / Check (pull_request) Successful in 38s
Continuous integration / Test Suite (pull_request) Successful in 43s
Continuous integration / Trunk (pull_request) Successful in 39s
Continuous integration / Rustfmt (pull_request) Successful in 32s
Continuous integration / Disallow unused dependencies (pull_request) Successful in 55s
Continuous integration / build (pull_request) Successful in 3m42s
Continuous integration / Check (push) Successful in 37s
Continuous integration / Test Suite (push) Successful in 45s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 50s
Continuous integration / Trunk (push) Successful in 1m39s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
2025-02-26 21:15:57 +00:00
e9aa97a089 fix(deps): update rust crate chrono to v0.4.40
All checks were successful
Continuous integration / Check (pull_request) Successful in 37s
Continuous integration / Test Suite (pull_request) Successful in 43s
Continuous integration / Trunk (pull_request) Successful in 38s
Continuous integration / build (pull_request) Successful in 51s
Continuous integration / Rustfmt (pull_request) Successful in 1m4s
Continuous integration / Disallow unused dependencies (pull_request) Successful in 55s
Continuous integration / Check (push) Successful in 37s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 50s
Continuous integration / Trunk (push) Successful in 1m37s
Continuous integration / Disallow unused dependencies (push) Successful in 55s
2025-02-26 08:46:20 +00:00
a82b047f75 fix(deps): update rust crate uuid to v1.15.0
All checks were successful
Continuous integration / Check (pull_request) Successful in 39s
Continuous integration / Test Suite (pull_request) Successful in 43s
Continuous integration / Trunk (pull_request) Successful in 38s
Continuous integration / Rustfmt (pull_request) Successful in 57s
Continuous integration / build (pull_request) Successful in 50s
Continuous integration / Disallow unused dependencies (pull_request) Successful in 2m27s
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 49s
Continuous integration / Trunk (push) Successful in 1m31s
Continuous integration / Disallow unused dependencies (push) Successful in 56s
2025-02-26 06:16:01 +00:00
9a8b44a8df fix(deps): update all non-major dependencies to 0.0.40
All checks were successful
Continuous integration / Test Suite (pull_request) Successful in 44s
Continuous integration / Check (pull_request) Successful in 1m48s
Continuous integration / Trunk (pull_request) Successful in 38s
Continuous integration / build (pull_request) Successful in 50s
Continuous integration / Rustfmt (pull_request) Successful in 1m3s
Continuous integration / Disallow unused dependencies (pull_request) Successful in 1m0s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Check (push) Successful in 1m49s
Continuous integration / Rustfmt (push) Successful in 30s
Continuous integration / Disallow unused dependencies (push) Successful in 54s
Continuous integration / build (push) Successful in 2m43s
2025-02-26 04:47:10 +00:00
a96693004c chore: Release
All checks were successful
Continuous integration / Test Suite (push) Successful in 42s
Continuous integration / Check (push) Successful in 2m9s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / build (push) Successful in 50s
Continuous integration / Rustfmt (push) Successful in 1m7s
Continuous integration / Disallow unused dependencies (push) Successful in 56s
2025-02-25 20:43:47 -08:00
ed9fe11fbf web: trimmed views for catchup mode 2025-02-25 20:43:27 -08:00
09fb14a796 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 37s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Trunk (push) Successful in 37s
Continuous integration / Rustfmt (push) Successful in 52s
Continuous integration / build (push) Successful in 50s
Continuous integration / Disallow unused dependencies (push) Successful in 2m28s
2025-02-25 20:08:44 -08:00
58a7936bba web: address lint 2025-02-25 20:08:31 -08:00
cd0ee361f5 chore: Release 2025-02-25 20:06:18 -08:00
77bd5abe0d Don't do incremental builds when release 2025-02-25 20:06:11 -08:00
450c5496b3 chore: Release 2025-02-25 20:04:01 -08:00
4411e45a3c Don't allow warnings when publishing 2025-02-25 20:03:40 -08:00
e7d20896d5 web: remove unnecessary Msg variant 2025-02-25 16:20:32 -08:00
32a1115abd chore: Release
Some checks failed
Continuous integration / Check (push) Successful in 38s
Continuous integration / Test Suite (push) Successful in 45s
Continuous integration / Trunk (push) Failing after 36s
Continuous integration / Rustfmt (push) Successful in 30s
Continuous integration / Disallow unused dependencies (push) Successful in 54s
Continuous integration / build (push) Successful in 2m44s
2025-02-25 15:58:46 -08:00
4982057500 web: more scroll to top improvements by reworking URL changes 2025-02-25 15:58:24 -08:00
8977f8bab5 chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 40s
Continuous integration / Test Suite (push) Successful in 43s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 30s
Continuous integration / build (push) Successful in 49s
Continuous integration / Disallow unused dependencies (push) Successful in 2m39s
2025-02-25 13:51:38 -08:00
0962a6b3cf web: improve scroll-to-top behavior 2025-02-25 13:51:11 -08:00
3c72929a4f web: enable properly styled buttons 2025-02-25 10:26:16 -08:00
e4eb495a70 web: properly exit catchup mode when done 2025-02-25 10:25:28 -08:00
00e8b0342e chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 37s
Continuous integration / Test Suite (push) Successful in 41s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 30s
Continuous integration / Disallow unused dependencies (push) Successful in 54s
Continuous integration / build (push) Successful in 2m46s
2025-02-24 18:41:19 -08:00
b1f9867c06 web: remove debug statement 2025-02-24 18:41:00 -08:00
77943b3570 web: scroll to top on page changes 2025-02-24 18:39:47 -08:00
45e4edb1dd web: add icons to catchup controls 2025-02-24 17:09:16 -08:00
9bf53afebf server: sort catchup ids by timestamp across all sources 2025-02-24 17:08:57 -08:00
e1a502ac4b chore: Release
All checks were successful
Continuous integration / Test Suite (push) Successful in 44s
Continuous integration / Check (push) Successful in 2m1s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 1m5s
Continuous integration / build (push) Successful in 50s
Continuous integration / Disallow unused dependencies (push) Successful in 2m38s
2025-02-24 14:56:17 -08:00
9346c46e62 web: change exit catchup behavior to view current message 2025-02-24 14:55:51 -08:00
10 changed files with 237 additions and 143 deletions

102
Cargo.lock generated
View File

@@ -562,9 +562,9 @@ dependencies = [
[[package]]
name = "build-info"
version = "0.0.39"
version = "0.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24c8169feaff1e5d9686706c0a56a54ed0422d2df41fa1c543e53f7cea0e70d4"
checksum = "288657edd15bfa5a7f30ca3b123c1af2c503eaf218e517fa10bc9063dbc2ad99"
dependencies = [
"bincode",
"build-info-common",
@@ -573,9 +573,9 @@ dependencies = [
[[package]]
name = "build-info-build"
version = "0.0.39"
version = "0.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e73a4a2bdb1e3fae84472b5a9f806208331eb89783bf9b19819cb1d8fbc6d5ec"
checksum = "3146483d5bc5081ec26f9c4e60232e770980d750b2802d6cc2563cded665cc73"
dependencies = [
"anyhow",
"base64 0.22.1",
@@ -593,21 +593,21 @@ dependencies = [
[[package]]
name = "build-info-common"
version = "0.0.39"
version = "0.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b6fa54101dfbd88efc3981859e92c3d47c729ff54d5df73ec36505c337e5c5e"
checksum = "8524ad59f5958f37f95e66bf6c9a8fa8440c4f56c069247c44244434cfca3eb1"
dependencies = [
"chrono",
"derive_more 1.0.0",
"derive_more 2.0.1",
"semver 1.0.25",
"serde",
]
[[package]]
name = "build-info-proc"
version = "0.0.39"
version = "0.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5458d2f0ed8bb88f7f6b5706460ca55fab08db16456ea03b920691b4cac163"
checksum = "6b58fb02636d968e8327d84a5a256df9704ac27a1eda98429c35dbe50a278f69"
dependencies = [
"anyhow",
"base64 0.22.1",
@@ -713,16 +713,16 @@ dependencies = [
[[package]]
name = "cargo_metadata"
version = "0.18.1"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
checksum = "8769706aad5d996120af43197bf46ef6ad0fda35216b4505f926a365a232d924"
dependencies = [
"camino",
"cargo-platform",
"semver 1.0.25",
"serde",
"serde_json",
"thiserror 1.0.69",
"thiserror 2.0.11",
]
[[package]]
@@ -772,9 +772,9 @@ dependencies = [
[[package]]
name = "chrono"
version = "0.4.39"
version = "0.4.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825"
checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c"
dependencies = [
"android-tzdata",
"iana-time-zone",
@@ -782,7 +782,7 @@ dependencies = [
"num-traits",
"serde",
"wasm-bindgen",
"windows-targets 0.52.6",
"windows-link",
]
[[package]]
@@ -910,9 +910,9 @@ dependencies = [
[[package]]
name = "console_log"
version = "0.1.2"
version = "0.1.4"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "e628484ff9348e6c256644436f215c0a9766867820da8cf161c567db1c877e32"
checksum = "d36495b7586d34322c3ffcff0e0d9d0b70f3a4ce88a9c199b3d8a01afb1debd7"
dependencies = [
"log",
"wasm-bindgen",
@@ -1337,18 +1337,18 @@ dependencies = [
[[package]]
name = "derive_more"
version = "1.0.0"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a9b99b9cbbe49445b21764dc0625032a89b145a2642e67603e1c936f5458d05"
checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678"
dependencies = [
"derive_more-impl",
]
[[package]]
name = "derive_more-impl"
version = "1.0.0"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7330aeadfbe296029522e6c40f315320aba36fc43a5b3632f3795348f3bd22"
checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3"
dependencies = [
"proc-macro2",
"quote",
@@ -1552,7 +1552,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -1620,9 +1620,9 @@ dependencies = [
[[package]]
name = "flate2"
version = "1.0.35"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc"
dependencies = [
"crc32fast",
"miniz_oxide",
@@ -1927,9 +1927,9 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "git2"
version = "0.19.0"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724"
checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff"
dependencies = [
"bitflags 2.8.0",
"libc",
@@ -2886,7 +2886,7 @@ checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37"
dependencies = [
"hermit-abi 0.4.0",
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -2965,7 +2965,7 @@ dependencies = [
[[package]]
name = "letterbox-notmuch"
version = "0.9.0"
version = "0.9.10"
dependencies = [
"itertools 0.14.0",
"log",
@@ -2980,14 +2980,14 @@ dependencies = [
[[package]]
name = "letterbox-procmail2notmuch"
version = "0.9.0"
version = "0.9.10"
dependencies = [
"anyhow",
]
[[package]]
name = "letterbox-server"
version = "0.9.0"
version = "0.9.10"
dependencies = [
"ammonia",
"anyhow",
@@ -3030,7 +3030,7 @@ dependencies = [
[[package]]
name = "letterbox-shared"
version = "0.9.0"
version = "0.9.10"
dependencies = [
"build-info",
"letterbox-notmuch",
@@ -3039,7 +3039,7 @@ dependencies = [
[[package]]
name = "letterbox-web"
version = "0.9.0"
version = "0.9.10"
dependencies = [
"build-info",
"build-info-build",
@@ -3057,6 +3057,7 @@ dependencies = [
"seed_hooks",
"serde",
"serde_json",
"strum_macros 0.27.1",
"thiserror 2.0.11",
"uuid",
"wasm-bindgen",
@@ -3078,9 +3079,9 @@ checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828"
[[package]]
name = "libgit2-sys"
version = "0.17.0+1.8.1"
version = "0.18.0+1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224"
checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec"
dependencies = [
"cc",
"libc",
@@ -4446,7 +4447,7 @@ dependencies = [
"once_cell",
"socket2",
"tracing",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5129,7 +5130,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5962,7 +5963,7 @@ version = "0.26.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06"
dependencies = [
"strum_macros",
"strum_macros 0.26.4",
]
[[package]]
@@ -5978,6 +5979,19 @@ dependencies = [
"syn 2.0.98",
]
[[package]]
name = "strum_macros"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8"
dependencies = [
"heck 0.5.0",
"proc-macro2",
"quote",
"rustversion",
"syn 2.0.98",
]
[[package]]
name = "subtle"
version = "1.0.0"
@@ -6205,7 +6219,7 @@ dependencies = [
"getrandom 0.3.1",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -7021,9 +7035,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "uuid"
version = "1.14.0"
version = "1.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93d59ca99a559661b96bf898d8fce28ed87935fd2bea9f05983c1464dd6c71b1"
checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587"
dependencies = [
"getrandom 0.3.1",
"js-sys",
@@ -7281,7 +7295,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.48.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -7308,6 +7322,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-link"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3"
[[package]]
name = "windows-registry"
version = "0.2.0"

View File

@@ -8,7 +8,7 @@ authors = ["Bill Thiede <git@xinu.tv>"]
edition = "2021"
license = "UNLICENSED"
publish = ["xinu"]
version = "0.9.0"
version = "0.9.10"
repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev]

View File

@@ -1,3 +1,6 @@
export CARGO_INCREMENTAL := "0"
export RUSTFLAGS := "-D warnings"
default:
@echo "Run: just patch|minor|major"

View File

@@ -17,7 +17,7 @@ anyhow = "1.0.79"
async-graphql = { version = "7", features = ["log"] }
async-graphql-rocket = "7"
async-trait = "0.1.81"
build-info = "0.0.39"
build-info = "0.0.40"
cacher = { version = "0.1.0", registry = "xinu" }
chrono = "0.4.39"
clap = { version = "4.5.23", features = ["derive"] }
@@ -48,11 +48,11 @@ urlencoding = "2.1.3"
#xtracing = { path = "../../xtracing" }
#xtracing = { git = "http://git-private.h.xinu.tv/wathiede/xtracing.git" }
xtracing = { version = "0.3.0", registry = "xinu" }
letterbox-notmuch = { version = "0.9.0", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.9.0", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.9.10", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.9.10", path = "../shared", registry = "xinu" }
[build-dependencies]
build-info-build = "0.0.39"
build-info-build = "0.0.40"
[features]
#default = [ "tantivy" ]

View File

@@ -331,10 +331,15 @@ impl QueryRoot {
notmuch_results.len(),
);
let results: Vec<_> = newsreader_results
let mut results: Vec<_> = newsreader_results
.into_iter()
.chain(notmuch_results)
.collect();
// The leading '-' is to reverse sort
results.sort_by_key(|item| match item {
ThreadSummaryCursor::Newsreader(_, ts) => -ts.timestamp,
ThreadSummaryCursor::Notmuch(_, ts) => -ts.timestamp,
});
let ids = results
.into_iter()
.map(|r| match r {

View File

@@ -11,6 +11,6 @@ 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.9.0", path = "../notmuch", registry = "xinu" }
build-info = "0.0.40"
letterbox-notmuch = { version = "0.9.10", path = "../notmuch", registry = "xinu" }
serde = { version = "1.0.147", features = ["derive"] }

View File

@@ -9,7 +9,7 @@ repository.workspace = true
version.workspace = true
[build-dependencies]
build-info-build = "0.0.39"
build-info-build = "0.0.40"
[dev-dependencies]
wasm-bindgen-test = "0.3.33"
@@ -28,14 +28,15 @@ graphql_client = "0.14.0"
thiserror = "2.0.0"
gloo-net = { version = "0.6.0", features = ["json", "serde_json"] }
human_format = "1.1.0"
build-info = "0.0.39"
build-info = "0.0.40"
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.9.0", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.9.0", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.9.10", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.9.10", path = "../notmuch", registry = "xinu" }
seed_hooks = { version = "0.4.0", registry = "xinu" }
strum_macros = "0.27.1"
[package.metadata.wasm-pack.profile.release]
wasm-opt = ['-Os']
@@ -49,4 +50,6 @@ features = [
"MediaQueryList",
"Navigator",
"Window",
"History",
"ScrollRestoration",
]

View File

@@ -18,6 +18,9 @@ fn main() {
#[cfg(debug_assertions)]
console_error_panic_hook::set_once();
#[cfg(debug_assertions)]
let lvl = Level::Debug;
#[cfg(not(debug_assertions))]
let lvl = Level::Info;
console_log::init_with_level(lvl).expect("failed to initialize console logging");
// Mount the `app` to the element with the `id` "app".

View File

@@ -29,16 +29,21 @@ pub fn unread_query() -> &'static str {
pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
let version = letterbox_shared::build_version(bi);
info!("Build Info: {}", version);
// Disable restoring to scroll position when navigating
window()
.history()
.expect("couldn't get history")
.set_scroll_restoration(web_sys::ScrollRestoration::Manual)
.expect("failed to set scroll restoration to manual");
if url.hash().is_none() {
orders.request_url(urls::search(unread_query(), 0));
} else {
orders.notify(subs::UrlRequested::new(url));
orders.request_url(url);
};
orders.stream(streams::window_event(Ev::Resize, |_| Msg::OnResize));
// TODO(wathiede): only do this while viewing the index? Or maybe add a new message that force
// 'notmuch new' on the server periodically?
orders.stream(streams::interval(30_000, || Msg::RefreshStart));
orders.subscribe(on_url_changed);
orders.subscribe(Msg::OnUrlChanged);
orders.stream(streams::window_event(Ev::Scroll, |_| Msg::WindowScrolled));
build_info::build_info!(fn bi);
@@ -54,18 +59,22 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
server: None,
},
catchup: None,
last_url: Url::current(),
}
}
fn on_url_changed(uc: subs::UrlChanged) -> Msg {
let mut url = uc.0;
fn on_url_changed(old: &Url, mut new: Url) -> Msg {
let did_change = *old != new;
let mut messages = Vec::new();
if did_change {
messages.push(Msg::ScrollToTop)
}
info!(
"url changed '{}', history {}",
url,
"url changed\nold '{old}'\nnew '{new}', history {}",
history().length().unwrap_or(0)
);
let hpp = url.remaining_hash_path_parts();
match hpp.as_slice() {
let hpp = new.remaining_hash_path_parts();
let msg = match hpp.as_slice() {
["t", tid] => Msg::ShowThreadRequest {
thread_id: tid.to_string(),
},
@@ -102,11 +111,14 @@ fn on_url_changed(uc: subs::UrlChanged) -> Msg {
last: None,
}
}
}
};
messages.push(msg);
Msg::MultiMsg(messages)
}
// `update` describes how to handle each `Msg`.
pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
debug!("update({})", msg);
match msg {
Msg::Noop => {}
Msg::RefreshStart => {
@@ -132,7 +144,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.perform_cmd(async move { Msg::Refresh });
}
Msg::Refresh => {
orders.perform_cmd(async move { on_url_changed(subs::UrlChanged(Url::current())) });
orders.request_url(Url::current());
}
Msg::Reload => {
window()
@@ -140,7 +152,10 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
.reload()
.expect("failed to reload window");
}
Msg::OnResize => (),
Msg::OnUrlChanged(new_url) => {
orders.send_msg(on_url_changed(&model.last_url, new_url.0.clone()));
model.last_url = new_url.0;
}
Msg::NextPage => {
match &model.context {
@@ -182,10 +197,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
};
}
Msg::GoToSearchResults => {
let url = urls::search(&model.query, 0);
info!("GoToSearchResults Start");
orders.request_url(url);
info!("GoToSearchResults End");
orders.send_msg(Msg::SearchQuery(model.query.clone()));
}
Msg::UpdateQuery(query) => model.query = query,
@@ -308,7 +320,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
})
.collect(),
);
info!("pager {:#?}", data.search.page_info);
let selected_threads = 'context: {
if let Context::SearchResult {
results,
@@ -536,7 +547,12 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
.expect("failed to copy to clipboard");
});
}
Msg::ScrollToTop => {
info!("scrolling to the top");
web_sys::window().unwrap().scroll_to_with_x_and_y(0., 0.);
}
Msg::WindowScrolled => {
// TODO: model.content_el doesn't go to None like it should when a DOM is recreated and the refrenced element goes away
if let Some(el) = model.content_el.get() {
let ih = window()
.inner_height()
@@ -586,13 +602,14 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
model.versions.server = Some(version);
}
Msg::StartCatchup => {
Msg::CatchupStart => {
let query = if model.query.contains("is:unread") {
model.query.to_string()
} else {
format!("{} is:unread", model.query)
};
info!("starting catchup mode w/ {}", query);
orders.send_msg(Msg::ScrollToTop);
orders.send_msg(Msg::CatchupRequest { query });
}
Msg::CatchupKeepUnread => {
@@ -608,23 +625,32 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::CatchupNext);
}
Msg::CatchupNext => {
orders.send_msg(Msg::ScrollToTop);
let Some(catchup) = &mut model.catchup else {
orders.send_msg(Msg::GoToSearchResults);
return;
};
let Some(idx) = catchup.items.iter().position(|i| !i.seen) else {
// All items have been seen
orders.send_msg(Msg::CatchupExit);
orders.send_msg(Msg::GoToSearchResults);
return;
};
catchup.items[idx].seen = true;
if idx < catchup.items.len() - 1 {
// Reached last item
orders.request_url(urls::thread(&catchup.items[idx + 1].id));
return;
} else {
orders.send_msg(Msg::CatchupExit);
orders.send_msg(Msg::GoToSearchResults);
return;
};
}
Msg::CatchupExit => {
orders.send_msg(Msg::ScrollToTop);
model.catchup = None;
}
}
}
@@ -656,6 +682,7 @@ pub struct Model {
pub content_el: ElRef<HtmlElement>,
pub versions: Version,
pub catchup: Option<Catchup>,
pub last_url: Url,
}
#[derive(Debug)]
@@ -714,14 +741,15 @@ pub enum RefreshingState {
Error(String),
}
// `Msg` describes the different events you can modify state with.
#[derive(strum_macros::Display)]
pub enum Msg {
Noop,
// Tell the client to refresh its state
Refresh,
// Tell the client to reload whole page from server
Reload,
// Window has changed size
OnResize,
// TODO: add GoToUrl
OnUrlChanged(subs::UrlChanged),
// Tell the server to update state
RefreshStart,
RefreshDone(Option<gloo_net::Error>),
@@ -774,12 +802,14 @@ pub enum Msg {
CopyToClipboard(String),
ScrollToTop,
WindowScrolled,
SetProgress(f64),
UpdateServerVersion(String),
StartCatchup,
CatchupStart,
CatchupKeepUnread,
CatchupMarkAsRead,
CatchupNext,
CatchupExit,
}

View File

@@ -4,7 +4,7 @@ use chrono::{DateTime, Datelike, Duration, Local, Utc};
use human_format::{Formatter, Scales};
use itertools::Itertools;
use letterbox_shared::compute_color;
use log::{debug, error, info};
use log::error;
use seed::{prelude::*, *};
use seed_hooks::{state_access::CloneState, topo, use_state, StateAccessEventHandlers};
use web_sys::{HtmlElement, HtmlInputElement};
@@ -21,6 +21,8 @@ use crate::{
const MAX_RAW_MESSAGE_SIZE: usize = 100_000;
mod tw_classes {
use seed::{prelude::*, *};
pub const TAG: &[&str] = &[
"rounded-md",
"px-2",
@@ -37,22 +39,30 @@ mod tw_classes {
"text-xs",
"[text-shadow:_0_1px_0_rgb(0_0_0_/_40%)]",
];
pub const BUTTON: &[&str] = &[
"bg-neutral-900",
"rounded-md",
"p-2",
"border",
"border-neutral-700",
"text-center",
"text-sm",
"transition-all",
"shadow-md",
"hover:shadow-lg",
"hover:bg-neutral-700",
"disabled:pointer-events-none",
"disabled:opacity-50",
"disabled:shadow-none",
];
// TODO: should this be a builder pattern?
pub fn button() -> seed::Attrs {
button_with_color("bg-neutral-900", "hover:bg-neutral-700")
}
pub fn button_with_color<T: ToClasses>(bg: T, hover: T) -> seed::Attrs {
C![
"rounded-md",
"p-2",
"border",
"border-neutral-700",
"text-center",
"text-sm",
"transition-all",
"shadow-md",
"hover:shadow-lg",
"disabled:pointer-events-none",
"disabled:opacity-50",
"disabled:shadow-none",
bg,
hover,
]
}
pub const CHECKBOX: &[&str] = &[
"w-8",
@@ -83,13 +93,13 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
thread(thread_data, open_messages, &model.content_el),
thread(thread_data, open_messages, &model.content_el, true),
&catchup.items,
model.read_completion_ratio,
)
} else {
normal_view(
thread(thread_data, open_messages, &model.content_el),
thread(thread_data, open_messages, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
@@ -104,13 +114,13 @@ pub fn view(model: &Model) -> Node<Msg> {
} => {
if let Some(catchup) = &model.catchup {
catchup_view(
news_post(post, &model.content_el),
news_post(post, &model.content_el, true),
&catchup.items,
model.read_completion_ratio,
)
} else {
normal_view(
news_post(post, &model.content_el),
news_post(post, &model.content_el, false),
&model.versions,
&model.query,
&model.refreshing_state,
@@ -188,19 +198,19 @@ fn catchup_view(
"p-4",
"border-b",
"border-gray-500",
"bg-black",
"bg-black/50",
],
div![
C!["absolute", "right-4", "text-gray-500"],
C!["absolute", "top-0", "right-4", "text-gray-500", "p-4"],
span![i![C!["fas", "fa-x"]]],
ev(Ev::Click, move |_| Msg::GoToSearchResults)
ev(Ev::Click, move |_| Msg::CatchupExit)
],
h1![
C!["text-center"],
format!("{} left ", items.iter().filter(|i| !i.seen).count(),)
]
],
div![C!["mt-12", "mb-4"], content],
div![C!["mt-12", "mb-20"], content],
div![
C![
"fixed",
@@ -213,17 +223,28 @@ fn catchup_view(
"p-4",
"border-t",
"border-gray-500",
"bg-black",
"bg-black/50",
],
button![
C![&tw_classes::BUTTON],
"Keep unread",
ev(Ev::Click, move |_| Msg::CatchupKeepUnread)
tw_classes::button(),
span![i![C!["far", "fa-envelope"]]],
span![C!["pl-2"], "Keep unread"],
ev(Ev::Click, |_| Msg::CatchupKeepUnread)
],
button![
C![&tw_classes::BUTTON, "bg-green-500"],
"Mark as read",
ev(Ev::Click, move |_| Msg::CatchupMarkAsRead)
tw_classes::button(),
span![i![C!["fas", "fa-house"]]],
span![C!["pl-2"], "Go home"],
ev(Ev::Click, |_| Msg::MultiMsg(vec![
Msg::CatchupExit,
Msg::GoToSearchResults
]))
],
button![
tw_classes::button_with_color("bg-green-800", "hover:bg-green-700"),
span![i![C!["far", "fa-envelope-open"]]],
span![C!["pl-2"], "Mark as read"],
ev(Ev::Click, |_| Msg::CatchupMarkAsRead)
]
],
reading_progress(read_completion_ratio)
@@ -445,11 +466,11 @@ fn search_toolbar(
div![
C!["gap-2", "flex", IF!(show_bulk_edit => "hidden")],
div![button![
C![&tw_classes::BUTTON],
tw_classes::button(),
attrs! {At::Title => "Mark as read"},
span![i![C!["far", "fa-eye"]]],
span![C!["pl-2", "hidden", "md:inline"], "Catch-up"],
ev(Ev::Click, |_| Msg::StartCatchup)
ev(Ev::Click, |_| Msg::CatchupStart)
]],
],
div![
@@ -474,14 +495,16 @@ fn search_toolbar(
],
div![
button![
C![&tw_classes::BUTTON, "rounded-r-none"],
tw_classes::button(),
C!["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"],
tw_classes::button(),
C!["rounded-l-none"],
attrs! {At::Title => "Mark as unread"},
span![i![C!["far", "fa-envelope"]]],
span![C!["pl-2", "hidden", "md:inline"], "Unread"],
@@ -489,7 +512,8 @@ fn search_toolbar(
]
],
div![button![
C![&tw_classes::BUTTON, "text-red-500"],
tw_classes::button(),
C!["text-red-500"],
attrs! {At::Title => "Mark as spam"},
span![i![C!["far", "fa-hand"]]],
span![C!["pl-2", "hidden", "md:inline"], "Spam"],
@@ -503,13 +527,13 @@ fn search_toolbar(
C!["flex", "gap-2", "items-center"],
p![format!("{count} results")],
button![
C![&tw_classes::BUTTON],
tw_classes::button(),
IF!(!pager.has_previous_page => attrs!{ At::Disabled=>true }),
"<",
IF!(pager.has_previous_page => ev(Ev::Click, |_| Msg::PreviousPage)),
],
button![
C![&tw_classes::BUTTON],
tw_classes::button(),
IF!(!pager.has_next_page => attrs!{ At::Disabled=>true }),
">",
IF!(pager.has_next_page => ev(Ev::Click, |_| Msg::NextPage))
@@ -1033,11 +1057,13 @@ fn render_attachements(
]
}
// TODO: add cathup_mode:bool and hide elements when true
#[topo::nested]
fn thread(
thread: &ShowThreadQueryThreadOnEmailThread,
open_messages: &HashSet<String>,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
) -> Node<Msg> {
// TODO(wathiede): show per-message subject if it changes significantly from top-level subject
let subject = if thread.subject.is_empty() {
@@ -1065,16 +1091,17 @@ fn thread(
let spam_add_thread_id = thread.thread_id.clone();
let spam_unread_thread_id = thread.thread_id.clone();
div![
C!["lg:p-4"],
C!["lg:p-4", "max-w-4xl"],
div![
C!["p-4", "lg:p-0"],
h3![C!["text-xl"], subject],
span![removable_tags_chiclet(&thread.thread_id, &tags)],
div![
IF!(!catchup_mode => div![
C!["pt-4", "gap-2", "flex", "justify-around"],
div![
button![
C![&tw_classes::BUTTON, "rounded-r-none"],
tw_classes::button(),
C!["rounded-r-none"],
attrs! {At::Title => "Mark as read"},
span![i![C!["far", "fa-envelope-open"]]],
span![C!["pl-2"], "Read"],
@@ -1084,7 +1111,8 @@ fn thread(
])),
],
button![
C![&tw_classes::BUTTON, "rounded-l-none"],
tw_classes::button(),
C!["rounded-l-none"],
attrs! {At::Title => "Mark as unread"},
span![i![C!["far", "fa-envelope"]]],
span![C!["pl-2"], "Unread"],
@@ -1095,7 +1123,8 @@ fn thread(
],
],
div![button![
C![&tw_classes::BUTTON, "text-red-500"],
tw_classes::button(),
C!["text-red-500"],
attrs! {At::Title => "Spam"},
span![i![C!["far", "fa-hand"]]],
span![C!["pl-2"], "Spam"],
@@ -1105,13 +1134,13 @@ fn thread(
Msg::GoToSearchResults
])),
]]
],
]),
],
div![
C!["lg:mt-4", "mail-thread"],
el_ref(content_el),
messages,
click_to_top()
IF!(!catchup_mode => click_to_top())
],
/* TODO(wathiede): plumb in orignal id
a![
@@ -1161,7 +1190,7 @@ fn view_header(
C!["flex", "px-4", "pt-4", "overflow-hidden"],
a![
C![IF![is_error => "bg-red-500"], "rounded-r-none"],
C![&tw_classes::BUTTON],
tw_classes::button(),
span![i![C![
"fa-solid",
"fa-arrow-rotate-right",
@@ -1170,7 +1199,7 @@ fn view_header(
ev(Ev::Click, |_| Msg::RefreshStart),
],
a![
C![&tw_classes::BUTTON],
tw_classes::button(),
C!["px-4", "rounded-none"],
attrs! {
At::Href => urls::search(unread_query(), 0)
@@ -1178,7 +1207,7 @@ fn view_header(
"Unread",
],
a![
C![&tw_classes::BUTTON],
tw_classes::button(),
C!["px-4", "rounded-none"],
attrs! {
At::Href => urls::search("", 0)
@@ -1250,11 +1279,7 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
],
IF!(t.unread>0 => format!("{}", t.unread))
],
ev(Ev::Click, |_| {
// Scroll window to the top when searching for a tag.
info!("scrolling to the top because you clicked a tag");
web_sys::window().unwrap().scroll_to_with_x_and_y(0., 0.);
})
ev(Ev::Click, |_| { Msg::ScrollToTop })
]
}
fn matches(a: &[&str], b: &[&str]) -> usize {
@@ -1334,7 +1359,13 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
]
]
}
fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElement>) -> Node<Msg> {
// TODO: add cathup_mode:bool and hide elements when true
fn news_post(
post: &ShowThreadQueryThreadOnNewsPost,
content_el: &ElRef<HtmlElement>,
catchup_mode: bool,
) -> Node<Msg> {
let subject = &post.title;
set_title(subject);
let read_thread_id = post.thread_id.clone();
@@ -1365,11 +1396,12 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
C!["p-4", "lg:p-0"],
h3![C!["text-xl"], subject],
span![tag(format!("News/{}", post.slug))],
div![
IF!(!catchup_mode => div![
C!["pt-4", "gap-2", "flex", "justify-around"],
div![
button![
C![&tw_classes::BUTTON, "rounded-r-none"],
tw_classes::button(),
C!["rounded-r-none"],
attrs! {At::Title => "Mark as read"},
span![i![C!["far", "fa-envelope-open"]]],
span![C!["pl-2"], "Read"],
@@ -1379,7 +1411,8 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
])),
],
button![
C![&tw_classes::BUTTON, "rounded-l-none"],
tw_classes::button(),
C!["rounded-l-none"],
attrs! {At::Title => "Mark as unread"},
span![i![C!["far", "fa-envelope"]]],
span![C!["pl-2"], "Unread"],
@@ -1391,7 +1424,7 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
],
// Placeholder for symmetry with email view that has Spam button
div![],
],
]),
],
div![
C!["lg:mt-4"],
@@ -1411,12 +1444,11 @@ fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElem
raw![&post.body]
]
],
click_to_top(),
IF!(!catchup_mode => click_to_top()),
]
}
fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg> {
let from = &post.site;
// TODO: move avatar/favicon stuff to the server side and and come up with a solution for emails
let id = post.thread_id.clone();
let is_unread = !post.is_read;
let url = &post.url;
@@ -1454,7 +1486,7 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
div![
C!["flex", "gap-2", "pt-2", "text-sm"],
a![
C![&tw_classes::BUTTON],
tw_classes::button(),
attrs! {
At::Href => post.url,
At::Target => "_blank",
@@ -1463,7 +1495,7 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
i![C!["fas", "fa-up-right-from-square"]],
],
a![
C![&tw_classes::BUTTON],
tw_classes::button(),
attrs! {
At::Href => add_archive_url,
At::Target => "_blank",
@@ -1472,7 +1504,7 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
i![C!["fas", "fa-plus"]],
],
a![
C![&tw_classes::BUTTON],
tw_classes::button(),
attrs! {
At::Href => view_archive_url,
At::Target => "_blank",
@@ -1524,7 +1556,6 @@ fn reading_progress(ratio: f64) -> Node<Msg> {
]
}
pub fn view_versions(versions: &Version) -> Node<Msg> {
debug!("versions {versions:?}");
aside![
C!["p-2"],
p![C!["uppercase", "font-bold"], "Versions"],
@@ -1539,11 +1570,10 @@ pub fn view_versions(versions: &Version) -> Node<Msg> {
fn click_to_top() -> Node<Msg> {
button![
C![&tw_classes::BUTTON, "bg-red-500", "lg:m-0", "m-4"],
tw_classes::button_with_color("bg-red-500", "hover:bg-neutral-700"),
C!["lg:m-0", "m-4"],
span!["Top"],
span![i![C!["fas", "fa-arrow-turn-up"]]],
ev(Ev::Click, |_| web_sys::window()
.unwrap()
.scroll_to_with_x_and_y(0., 0.))
ev(Ev::Click, |_| Msg::ScrollToTop)
]
}