Compare commits

...

5 Commits

Author SHA1 Message Date
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
8 changed files with 44 additions and 29 deletions

10
Cargo.lock generated
View File

@ -2965,7 +2965,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-notmuch" name = "letterbox-notmuch"
version = "0.9.1" version = "0.9.2"
dependencies = [ dependencies = [
"itertools 0.14.0", "itertools 0.14.0",
"log", "log",
@ -2980,14 +2980,14 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-procmail2notmuch" name = "letterbox-procmail2notmuch"
version = "0.9.1" version = "0.9.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
] ]
[[package]] [[package]]
name = "letterbox-server" name = "letterbox-server"
version = "0.9.1" version = "0.9.2"
dependencies = [ dependencies = [
"ammonia", "ammonia",
"anyhow", "anyhow",
@ -3030,7 +3030,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-shared" name = "letterbox-shared"
version = "0.9.1" version = "0.9.2"
dependencies = [ dependencies = [
"build-info", "build-info",
"letterbox-notmuch", "letterbox-notmuch",
@ -3039,7 +3039,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-web" name = "letterbox-web"
version = "0.9.1" version = "0.9.2"
dependencies = [ dependencies = [
"build-info", "build-info",
"build-info-build", "build-info-build",

View File

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

View File

@ -48,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.3.0", registry = "xinu" } xtracing = { version = "0.3.0", registry = "xinu" }
letterbox-notmuch = { version = "0.9.1", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.2", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.9.1", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.9.2", path = "../shared", registry = "xinu" }
[build-dependencies] [build-dependencies]
build-info-build = "0.0.39" build-info-build = "0.0.39"

View File

@ -331,10 +331,15 @@ impl QueryRoot {
notmuch_results.len(), notmuch_results.len(),
); );
let results: Vec<_> = newsreader_results let mut results: Vec<_> = newsreader_results
.into_iter() .into_iter()
.chain(notmuch_results) .chain(notmuch_results)
.collect(); .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 let ids = results
.into_iter() .into_iter()
.map(|r| match r { .map(|r| match r {

View File

@ -12,5 +12,5 @@ version.workspace = true
[dependencies] [dependencies]
build-info = "0.0.39" build-info = "0.0.39"
letterbox-notmuch = { version = "0.9.1", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.2", path = "../notmuch", registry = "xinu" }
serde = { version = "1.0.147", features = ["derive"] } serde = { version = "1.0.147", features = ["derive"] }

View File

@ -33,8 +33,8 @@ 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.9.1", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.9.2", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.9.1", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.2", path = "../notmuch", registry = "xinu" }
seed_hooks = { version = "0.4.0", registry = "xinu" } seed_hooks = { version = "0.4.0", registry = "xinu" }
[package.metadata.wasm-pack.profile.release] [package.metadata.wasm-pack.profile.release]

View File

@ -59,13 +59,20 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
fn on_url_changed(uc: subs::UrlChanged) -> Msg { fn on_url_changed(uc: subs::UrlChanged) -> Msg {
let mut url = uc.0; let mut url = uc.0;
let href = document().location().unwrap().href().unwrap();
let origin = document().location().unwrap().origin().unwrap();
let current_url = &href[origin.len()..];
let did_change = current_url != url.to_string();
let mut messages = Vec::new();
if did_change {
messages.push(Msg::ScrollToTop)
}
info!( info!(
"url changed '{}', history {}", "url changed\nold '{current_url}'\nnew '{url}', history {}",
url,
history().length().unwrap_or(0) history().length().unwrap_or(0)
); );
let hpp = url.remaining_hash_path_parts(); let hpp = url.remaining_hash_path_parts();
match hpp.as_slice() { let msg = match hpp.as_slice() {
["t", tid] => Msg::ShowThreadRequest { ["t", tid] => Msg::ShowThreadRequest {
thread_id: tid.to_string(), thread_id: tid.to_string(),
}, },
@ -102,7 +109,9 @@ fn on_url_changed(uc: subs::UrlChanged) -> Msg {
last: None, last: None,
} }
} }
} };
messages.push(msg);
Msg::MultiMsg(messages)
} }
// `update` describes how to handle each `Msg`. // `update` describes how to handle each `Msg`.
@ -308,7 +317,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
}) })
.collect(), .collect(),
); );
info!("pager {:#?}", data.search.page_info);
let selected_threads = 'context: { let selected_threads = 'context: {
if let Context::SearchResult { if let Context::SearchResult {
results, results,
@ -536,6 +544,10 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
.expect("failed to copy to clipboard"); .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 => { Msg::WindowScrolled => {
if let Some(el) = model.content_el.get() { if let Some(el) = model.content_el.get() {
let ih = window() let ih = window()
@ -608,6 +620,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::CatchupNext); orders.send_msg(Msg::CatchupNext);
} }
Msg::CatchupNext => { Msg::CatchupNext => {
orders.send_msg(Msg::ScrollToTop);
let Some(catchup) = &mut model.catchup else { let Some(catchup) = &mut model.catchup else {
orders.send_msg(Msg::GoToSearchResults); orders.send_msg(Msg::GoToSearchResults);
return; return;
@ -777,6 +790,7 @@ pub enum Msg {
CopyToClipboard(String), CopyToClipboard(String),
ScrollToTop,
WindowScrolled, WindowScrolled,
SetProgress(f64), SetProgress(f64),
UpdateServerVersion(String), UpdateServerVersion(String),

View File

@ -4,7 +4,7 @@ use chrono::{DateTime, Datelike, Duration, Local, Utc};
use human_format::{Formatter, Scales}; use human_format::{Formatter, Scales};
use itertools::Itertools; use itertools::Itertools;
use letterbox_shared::compute_color; use letterbox_shared::compute_color;
use log::{debug, error, info}; use log::{debug, error};
use seed::{prelude::*, *}; use seed::{prelude::*, *};
use seed_hooks::{state_access::CloneState, topo, use_state, StateAccessEventHandlers}; use seed_hooks::{state_access::CloneState, topo, use_state, StateAccessEventHandlers};
use web_sys::{HtmlElement, HtmlInputElement}; use web_sys::{HtmlElement, HtmlInputElement};
@ -217,12 +217,14 @@ fn catchup_view(
], ],
button![ button![
C![&tw_classes::BUTTON], C![&tw_classes::BUTTON],
"Keep unread", span![i![C!["far", "fa-envelope"]]],
span![C!["pl-2"], "Keep unread"],
ev(Ev::Click, move |_| Msg::CatchupKeepUnread) ev(Ev::Click, move |_| Msg::CatchupKeepUnread)
], ],
button![ button![
C![&tw_classes::BUTTON, "bg-green-500"], C![&tw_classes::BUTTON, "bg-green-500"],
"Mark as read", span![i![C!["far", "fa-envelope-open"]]],
span![C!["pl-2"], "Mark as read"],
ev(Ev::Click, move |_| Msg::CatchupMarkAsRead) ev(Ev::Click, move |_| Msg::CatchupMarkAsRead)
] ]
], ],
@ -1065,7 +1067,7 @@ fn thread(
let spam_add_thread_id = thread.thread_id.clone(); let spam_add_thread_id = thread.thread_id.clone();
let spam_unread_thread_id = thread.thread_id.clone(); let spam_unread_thread_id = thread.thread_id.clone();
div![ div![
C!["lg:p-4"], C!["lg:p-4", "max-w-4xl"],
div![ div![
C!["p-4", "lg:p-0"], C!["p-4", "lg:p-0"],
h3![C!["text-xl"], subject], h3![C!["text-xl"], subject],
@ -1250,11 +1252,7 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
], ],
IF!(t.unread>0 => format!("{}", t.unread)) IF!(t.unread>0 => format!("{}", t.unread))
], ],
ev(Ev::Click, |_| { ev(Ev::Click, |_| { Msg::ScrollToTop })
// 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.);
})
] ]
} }
fn matches(a: &[&str], b: &[&str]) -> usize { fn matches(a: &[&str], b: &[&str]) -> usize {
@ -1542,8 +1540,6 @@ fn click_to_top() -> Node<Msg> {
C![&tw_classes::BUTTON, "bg-red-500", "lg:m-0", "m-4"], C![&tw_classes::BUTTON, "bg-red-500", "lg:m-0", "m-4"],
span!["Top"], span!["Top"],
span![i![C!["fas", "fa-arrow-turn-up"]]], span![i![C!["fas", "fa-arrow-turn-up"]]],
ev(Ev::Click, |_| web_sys::window() ev(Ev::Click, |_| Msg::ScrollToTop)
.unwrap()
.scroll_to_with_x_and_y(0., 0.))
] ]
} }