Compare commits

..

No commits in common. "32a1115abd1721ff70700154e5d7537237970a63" and "8977f8bab5b312ee349d2eb44cffdc350d5997fc" have entirely different histories.

8 changed files with 27 additions and 36 deletions

18
Cargo.lock generated
View File

@ -910,9 +910,9 @@ dependencies = [
[[package]] [[package]]
name = "console_log" name = "console_log"
version = "0.1.4" version = "0.1.2"
source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/" source = "sparse+https://git.z.xinu.tv/api/packages/wathiede/cargo/"
checksum = "d36495b7586d34322c3ffcff0e0d9d0b70f3a4ce88a9c199b3d8a01afb1debd7" checksum = "e628484ff9348e6c256644436f215c0a9766867820da8cf161c567db1c877e32"
dependencies = [ dependencies = [
"log", "log",
"wasm-bindgen", "wasm-bindgen",
@ -1620,9 +1620,9 @@ dependencies = [
[[package]] [[package]]
name = "flate2" name = "flate2"
version = "1.1.0" version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c"
dependencies = [ dependencies = [
"crc32fast", "crc32fast",
"miniz_oxide", "miniz_oxide",
@ -2965,7 +2965,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-notmuch" name = "letterbox-notmuch"
version = "0.9.4" version = "0.9.3"
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.4" version = "0.9.3"
dependencies = [ dependencies = [
"anyhow", "anyhow",
] ]
[[package]] [[package]]
name = "letterbox-server" name = "letterbox-server"
version = "0.9.4" version = "0.9.3"
dependencies = [ dependencies = [
"ammonia", "ammonia",
"anyhow", "anyhow",
@ -3030,7 +3030,7 @@ dependencies = [
[[package]] [[package]]
name = "letterbox-shared" name = "letterbox-shared"
version = "0.9.4" version = "0.9.3"
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.4" version = "0.9.3"
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.4" version = "0.9.3"
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.4", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.3", path = "../notmuch", registry = "xinu" }
letterbox-shared = { version = "0.9.4", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.9.3", path = "../shared", registry = "xinu" }
[build-dependencies] [build-dependencies]
build-info-build = "0.0.39" build-info-build = "0.0.39"

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.4", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.3", 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.4", path = "../shared", registry = "xinu" } letterbox-shared = { version = "0.9.3", path = "../shared", registry = "xinu" }
letterbox-notmuch = { version = "0.9.4", path = "../notmuch", registry = "xinu" } letterbox-notmuch = { version = "0.9.3", 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

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

View File

@ -32,13 +32,13 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
if url.hash().is_none() { if url.hash().is_none() {
orders.request_url(urls::search(unread_query(), 0)); orders.request_url(urls::search(unread_query(), 0));
} else { } else {
orders.request_url(url); orders.notify(subs::UrlRequested::new(url));
}; };
orders.stream(streams::window_event(Ev::Resize, |_| Msg::OnResize)); 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 // TODO(wathiede): only do this while viewing the index? Or maybe add a new message that force
// 'notmuch new' on the server periodically? // 'notmuch new' on the server periodically?
orders.stream(streams::interval(30_000, || Msg::RefreshStart)); orders.stream(streams::interval(30_000, || Msg::RefreshStart));
orders.subscribe(Msg::OnUrlChanged); orders.subscribe(on_url_changed);
orders.stream(streams::window_event(Ev::Scroll, |_| Msg::WindowScrolled)); orders.stream(streams::window_event(Ev::Scroll, |_| Msg::WindowScrolled));
build_info::build_info!(fn bi); build_info::build_info!(fn bi);
@ -54,21 +54,24 @@ pub fn init(url: Url, orders: &mut impl Orders<Msg>) -> Model {
server: None, server: None,
}, },
catchup: None, catchup: None,
last_url: Url::current(),
} }
} }
fn on_url_changed(old: &Url, mut new: Url) -> Msg { fn on_url_changed(uc: subs::UrlChanged) -> Msg {
let did_change = *old != new; 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(); let mut messages = Vec::new();
if did_change { if did_change {
messages.push(Msg::ScrollToTop) messages.push(Msg::ScrollToTop)
} }
info!( info!(
"url changed\nold '{old}'\nnew '{new}', history {}", "url changed\nold '{current_url}'\nnew '{url}', history {}",
history().length().unwrap_or(0) history().length().unwrap_or(0)
); );
let hpp = new.remaining_hash_path_parts(); let hpp = url.remaining_hash_path_parts();
let msg = 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(),
@ -139,7 +142,7 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
orders.perform_cmd(async move { Msg::Refresh }); orders.perform_cmd(async move { Msg::Refresh });
} }
Msg::Refresh => { Msg::Refresh => {
orders.request_url(Url::current()); orders.perform_cmd(async move { on_url_changed(subs::UrlChanged(Url::current())) });
} }
Msg::Reload => { Msg::Reload => {
window() window()
@ -147,10 +150,6 @@ pub fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) {
.reload() .reload()
.expect("failed to reload window"); .expect("failed to reload window");
} }
Msg::OnUrlChanged(new_url) => {
orders.send_msg(on_url_changed(&model.last_url, new_url.0.clone()));
model.last_url = new_url.0;
}
Msg::OnResize => (), Msg::OnResize => (),
Msg::NextPage => { Msg::NextPage => {
@ -677,7 +676,6 @@ pub struct Model {
pub content_el: ElRef<HtmlElement>, pub content_el: ElRef<HtmlElement>,
pub versions: Version, pub versions: Version,
pub catchup: Option<Catchup>, pub catchup: Option<Catchup>,
pub last_url: Url,
} }
#[derive(Debug)] #[derive(Debug)]
@ -743,8 +741,6 @@ pub enum Msg {
Refresh, Refresh,
// Tell the client to reload whole page from server // Tell the client to reload whole page from server
Reload, Reload,
// TODO: add GoToUrl
OnUrlChanged(subs::UrlChanged),
// Window has changed size // Window has changed size
OnResize, OnResize,
// Tell the server to update state // Tell the server to update state

View File

@ -1048,7 +1048,6 @@ fn render_attachements(
] ]
} }
// TODO: add cathup_mode:bool and hide elements when true
#[topo::nested] #[topo::nested]
fn thread( fn thread(
thread: &ShowThreadQueryThreadOnEmailThread, thread: &ShowThreadQueryThreadOnEmailThread,
@ -1349,8 +1348,6 @@ pub fn view_tags(tags: &Option<Vec<Tag>>) -> Node<Msg> {
] ]
] ]
} }
// TODO: add cathup_mode:bool and hide elements when true
fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElement>) -> Node<Msg> { fn news_post(post: &ShowThreadQueryThreadOnNewsPost, content_el: &ElRef<HtmlElement>) -> Node<Msg> {
let subject = &post.title; let subject = &post.title;
set_title(subject); set_title(subject);
@ -1543,6 +1540,7 @@ fn reading_progress(ratio: f64) -> Node<Msg> {
] ]
} }
pub fn view_versions(versions: &Version) -> Node<Msg> { pub fn view_versions(versions: &Version) -> Node<Msg> {
debug!("versions {versions:?}");
aside![ aside![
C!["p-2"], C!["p-2"],
p![C!["uppercase", "font-bold"], "Versions"], p![C!["uppercase", "font-bold"], "Versions"],