Compare commits

..

7 Commits

Author SHA1 Message Date
e01dabe6ed chore: Release
All checks were successful
Continuous integration / Check (push) Successful in 36s
Continuous integration / Test Suite (push) Successful in 40s
Continuous integration / Trunk (push) Successful in 38s
Continuous integration / Rustfmt (push) Successful in 31s
Continuous integration / build (push) Successful in 48s
Continuous integration / Disallow unused dependencies (push) Successful in 57s
2025-04-13 22:01:29 -07:00
ecaf0dd0fc web: remove unused import 2025-04-13 22:01:17 -07:00
3d4dcc9e6b chore: Release 2025-04-13 20:53:47 -07:00
28a5d9f219 web: add buttons for just unread news and unread mail 2025-04-13 20:53:19 -07:00
81876d37ea web: fix click handling in news post header 2025-04-13 20:53:19 -07:00
4a6b159ddb web: always show bulk-edit checkbox, fix check logic 2025-04-13 20:53:19 -07:00
d84957cc8c web: use current thread, not first !seen in catchup mode 2025-04-13 20:53:19 -07:00
7 changed files with 119 additions and 87 deletions

10
Cargo.lock generated
View File

@ -3001,7 +3001,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-notmuch" name = "letterbox-notmuch"
version = "0.10.13" version = "0.12.0"
dependencies = [ dependencies = [
"itertools", "itertools",
"log", "log",
@ -3016,14 +3016,14 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-procmail2notmuch" name = "letterbox-procmail2notmuch"
version = "0.10.13" version = "0.12.0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
] ]
[[package]] [[package]]
name = "letterbox-server" name = "letterbox-server"
version = "0.10.13" version = "0.12.0"
dependencies = [ dependencies = [
"ammonia", "ammonia",
"anyhow", "anyhow",
@ -3065,7 +3065,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-shared" name = "letterbox-shared"
version = "0.10.13" version = "0.12.0"
dependencies = [ dependencies = [
"build-info", "build-info",
"letterbox-notmuch", "letterbox-notmuch",
@ -3074,7 +3074,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-web" name = "letterbox-web"
version = "0.10.13" version = "0.12.0"
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.10.13" version = "0.12.0"
repository = "https://git.z.xinu.tv/wathiede/letterbox" repository = "https://git.z.xinu.tv/wathiede/letterbox"
[profile.dev] [profile.dev]

View File

@ -47,8 +47,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.10.13", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.12.0", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.10.13", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.12.0", path = "../shared", registry = "xinu" }
[build-dependencies] [build-dependencies]
build-info-build = "0.0.40" build-info-build = "0.0.40"

View File

@ -12,5 +12,5 @@ version.workspace = true
[dependencies] [dependencies]
build-info = "0.0.40" build-info = "0.0.40"
letterbox-notmuch = { version = "0.10.13", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.12.0", 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.10.13", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.12.0", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.10.13", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.12.0", path = "../notmuch", registry = "xinu" }
seed_hooks = { version = "0.4.0", registry = "xinu" } seed_hooks = { version = "0.4.0", registry = "xinu" }
strum_macros = "0.27.1" strum_macros = "0.27.1"

View File

@ -616,9 +616,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::CatchupRequest { query }); orders.send_msg(Msg::CatchupRequest { query });
} }
Msg::CatchupKeepUnread => { Msg::CatchupKeepUnread => {
if let Some(thread_id) = current_thread_id(&model.context) {
orders.send_msg(Msg::SetUnread(thread_id, true));
};
orders.send_msg(Msg::CatchupNext); orders.send_msg(Msg::CatchupNext);
} }
Msg::CatchupMarkAsRead => { Msg::CatchupMarkAsRead => {
@ -633,7 +630,15 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.send_msg(Msg::GoToSearchResults); orders.send_msg(Msg::GoToSearchResults);
return; return;
}; };
let Some(idx) = catchup.items.iter().position(|i| !i.seen) else { let Some(thread_id) = current_thread_id(&model.context) else {
return;
};
let Some(idx) = catchup
.items
.iter()
.inspect(|i| info!("i {i:?} thread_id {thread_id}"))
.position(|i| i.id == thread_id)
else {
// All items have been seen // All items have been seen
orders.send_msg(Msg::CatchupExit); orders.send_msg(Msg::CatchupExit);
orders.send_msg(Msg::GoToSearchResults); orders.send_msg(Msg::GoToSearchResults);
@ -726,6 +731,7 @@ pub struct Catchup {
pub items: Vec<CatchupItem>, pub items: Vec<CatchupItem>,
} }
#[derive(Debug)]
pub struct CatchupItem { pub struct CatchupItem {
pub id: String, pub id: String,
pub seen: bool, pub seen: bool,
@ -759,6 +765,7 @@ pub enum Msg {
NextPage, NextPage,
PreviousPage, PreviousPage,
GoToSearchResults, GoToSearchResults,
UpdateQuery(String), UpdateQuery(String),
SearchQuery(String), SearchQuery(String),

View File

@ -12,7 +12,7 @@ use web_sys::{HtmlElement, HtmlInputElement};
use crate::{ use crate::{
api::urls, api::urls,
graphql::{front_page_query::*, show_thread_query::*}, graphql::{front_page_query::*, show_thread_query::*},
state::{unread_query, CatchupItem, Context, Model, Msg, RefreshingState, Tag, Version}, state::{CatchupItem, Context, Model, Msg, RefreshingState, Tag, Version},
}; };
// TODO(wathiede): create a QueryString enum that wraps single and multiple message ids and thread // TODO(wathiede): create a QueryString enum that wraps single and multiple message ids and thread
@ -468,38 +468,42 @@ fn search_toolbar(
if let Some(tri) = tri.get() { if let Some(tri) = tri.get() {
tri.set_indeterminate(indeterminate); tri.set_indeterminate(indeterminate);
} }
let catchup = div![button![
tw_classes::button(),
attrs! {At::Title => "Catch up"},
span![i![C!["far", "fa-eye"]]],
span![C!["pl-2", "hidden", "md:inline"], "Catch-up"],
ev(Ev::Click, |_| Msg::CatchupStart)
]];
let tristate_input = div![
C!["flex", "items-center", "mr-4"],
input![
&tri,
C![&tw_classes::CHECKBOX],
attrs! {
At::Type=>"checkbox",
},
IF!(all_selected=>attrs!{At::Checked=>true})
],
ev(Ev::Input, move |_| {
if all_selected {
Msg::SelectionSetNone
} else {
Msg::SelectionSetAll
}
}),
];
nav![ nav![
C!["py-4", "flex", "w-full", "justify-between"], C!["py-4", "flex", "w-full", "justify-between"],
div![ div![
C!["gap-2", "flex", IF!(show_bulk_edit => "hidden")], C!["gap-2", "flex", IF!(show_bulk_edit => "hidden")],
div![button![ &tristate_input,
tw_classes::button(), &catchup
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::CatchupStart)
]],
], ],
div![ div![
C!["gap-2", "flex", IF!(!show_bulk_edit => "hidden")], C!["gap-2", "flex", IF!(!show_bulk_edit => "hidden")],
div![ &tristate_input,
C!["flex", "items-center", "mr-4"], &catchup,
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![ div![
button![ button![
tw_classes::button(), tw_classes::button(),
@ -1208,47 +1212,68 @@ fn view_header(
let query = Url::decode_uri_component(query).unwrap_or("".to_string()); let query = Url::decode_uri_component(query).unwrap_or("".to_string());
nav![ nav![
C!["flex", "px-4", "pt-4", "overflow-hidden"], C!["flex", "flex-col"],
a![ div![
C![IF![is_error => "bg-red-500"], "rounded-r-none"], C!["flex-auto", "flex"],
tw_classes::button(), button![
span![i![C![ C![IF![is_error => "bg-red-500"], "rounded-none"],
"fa-solid", tw_classes::button(),
"fa-arrow-rotate-right", span![i![C![
IF![is_loading => "animate-spin"], "fa-solid",
]]], "fa-arrow-rotate-right",
ev(Ev::Click, |_| Msg::RefreshStart), IF![is_loading => "animate-spin"],
]]],
ev(Ev::Click, |_| Msg::RefreshStart),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
"All",
ev(Ev::Click, |_| Msg::SearchQuery(String::new())),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" Unread",
ev(Ev::Click, |_| Msg::SearchQuery("is:unread".to_string())),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" News",
ev(Ev::Click, |_| Msg::SearchQuery(
"is:unread is:news".to_string()
)),
],
button![
tw_classes::button(),
C!["grow", "rounded-none"],
span![i![C!["far", "fa-envelope"]]],
" Mail",
ev(Ev::Click, |_| Msg::SearchQuery(
"is:unread is:mail".to_string()
)),
],
], ],
a![ div![
tw_classes::button(), C!["flex-auto", "flex"],
C!["px-4", "rounded-none"], input![
attrs! { C!["grow", "text-black", "m-2", "p-1"],
At::Href => urls::search(unread_query(), 0) attrs! {
}, At::Placeholder => "Search";
"Unread", At::AutoFocus => auto_focus_search.as_at_value();
], At::Value => query,
a![ },
tw_classes::button(), input_ev(Ev::Input, |q| Msg::UpdateQuery(q)),
C!["px-4", "rounded-none"], // Send search on enter.
attrs! { keyboard_ev(Ev::KeyUp, move |e| if e.key_code() == 0x0d {
At::Href => urls::search("", 0) Msg::SearchQuery(query)
}, } else {
"All", Msg::Noop
], }),
input![ ]
C!["grow", "pl-2", "text-black", "rounded-r"],
attrs! {
At::Placeholder => "Search";
At::AutoFocus => auto_focus_search.as_at_value();
At::Value => query,
},
input_ev(Ev::Input, |q| Msg::UpdateQuery(q)),
// Send search on enter.
keyboard_ev(Ev::KeyUp, move |e| if e.key_code() == 0x0d {
Msg::SearchQuery(query)
} else {
Msg::Noop
}),
] ]
] ]
} }
@ -1555,12 +1580,12 @@ fn render_news_post_header(post: &ShowThreadQueryThreadOnNewsPost) -> Node<Msg>
} else { } else {
"fa-envelope-open" "fa-envelope-open"
}, },
]] ]],
], ev(Ev::Click, move |e| {
ev(Ev::Click, move |e| { e.stop_propagation();
e.stop_propagation(); Msg::SetUnread(id, !is_unread)
Msg::SetUnread(id, !is_unread) })
}) ]
] ]
} }
fn reading_progress(ratio: f64) -> Node<Msg> { fn reading_progress(ratio: f64) -> Node<Msg> {