From f8e0293eb15fb5fef4a941a3f05b51092c1a272b Mon Sep 17 00:00:00 2001 From: John Lewis Date: Wed, 17 Sep 2025 14:41:30 -0700 Subject: [PATCH 1/4] chore(app): re-enable dark mode --- crates/site-app/style/src/main.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/site-app/style/src/main.css b/crates/site-app/style/src/main.css index b467223a..e46c7b8d 100644 --- a/crates/site-app/style/src/main.css +++ b/crates/site-app/style/src/main.css @@ -6,7 +6,7 @@ @import "tailwindcss-radix-colors/dist/red-colors-only.css"; @import "./theme/colors.css"; -/* @import "./theme/colors-dark.css"; */ +@import "./theme/colors-dark.css"; @import "./components/btn.css"; @import "./components/btn-link.css"; From f94e37008498d70e63b59bf364263738a04b31be Mon Sep 17 00:00:00 2001 From: John Lewis Date: Wed, 17 Sep 2025 14:45:18 -0700 Subject: [PATCH 2/4] feat(app): add definition tracking to `OrgHook` --- crates/site-app/src/hooks/org_hook.rs | 74 +++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/crates/site-app/src/hooks/org_hook.rs b/crates/site-app/src/hooks/org_hook.rs index 80b5e553..1f11a121 100644 --- a/crates/site-app/src/hooks/org_hook.rs +++ b/crates/site-app/src/hooks/org_hook.rs @@ -1,3 +1,5 @@ +use std::panic::Location; + use leptos::prelude::*; use leptos_fetch::QueryClient; use models::{dvf::RecordId, AuthUser, Org, PvOrg}; @@ -6,38 +8,75 @@ use crate::{pages::RequestedOrg, resources::org::org_query_scope}; #[derive(Clone)] pub struct OrgHook { - key: Callback<(), RecordId>, - resource: Resource, ServerFnError>>, - user: AuthUser, + #[cfg(debug_assertions)] + defined_at: &'static Location<'static>, + key: Callback<(), RecordId>, + resource: Resource, ServerFnError>>, + user: AuthUser, } impl OrgHook { - /// Creates a new [`OrgHook`]. Requires [`AuthUser`] in context. - pub fn new( + fn new_inner( key: impl Fn() -> RecordId + Copy + Send + Sync + 'static, + defined_at: &'static Location, ) -> Self { - let auth_user = expect_context(); - let client = expect_context::(); + let auth_user = use_context().unwrap_or_else(|| { + panic!( + "context of type `AuthUser` was not found by `OrgHook` defined at {}", + defined_at + ) + }); + let client = use_context::().unwrap_or_else(|| { + panic!( + "context of type `QueryClient` was not found by `OrgHook` defined at \ + {}", + defined_at + ) + }); let resource = client.resource(org_query_scope(), key); OrgHook { + #[cfg(debug_assertions)] + defined_at, key: Callback::new(move |_| key()), resource, user: auth_user, } } + /// Creates a new [`OrgHook`]. Requires [`AuthUser`] in context. + #[track_caller] + pub fn new( + key: impl Fn() -> RecordId + Copy + Send + Sync + 'static, + ) -> Self { + Self::new_inner(key, Location::caller()) + } + /// Creates a new [`OrgHook`] using the [`AuthUser`]'s active org. + #[track_caller] pub fn new_active() -> Self { - let auth_user = expect_context::(); + let defined_at = Location::caller(); + let auth_user = use_context::().unwrap_or_else(|| { + panic!( + "context of type `AuthUser` was not found by `OrgHook` defined at \ + {defined_at}", + ) + }); let active_org = auth_user.active_org(); - Self::new(move || active_org) + Self::new_inner(move || active_org, defined_at) } /// Creates a new [`OrgHook`] using the [`RequestedOrg`] in context. + #[track_caller] pub fn new_requested() -> Self { - let RequestedOrg(requested_org) = expect_context(); - Self::new(move || requested_org) + let defined_at = Location::caller(); + let RequestedOrg(requested_org) = use_context().unwrap_or_else(|| { + panic!( + "context of type `RequestedOrg` was not found by `OrgHook` defined at \ + {defined_at}", + ) + }); + Self::new_inner(move || requested_org, defined_at) } pub fn key( @@ -80,3 +119,16 @@ impl OrgHook { }) } } + +impl DefinedAt for OrgHook { + fn defined_at(&self) -> Option<&'static Location<'static>> { + #[cfg(debug_assertions)] + { + Some(self.defined_at) + } + #[cfg(not(debug_assertions))] + { + None + } + } +} From 66bfcea69a26c5c45ba64b6003a64559cd809cdf Mon Sep 17 00:00:00 2001 From: John Lewis Date: Wed, 17 Sep 2025 14:45:18 -0700 Subject: [PATCH 3/4] feat(deps): use local-action-patched leptos --- Cargo.lock | 85 ++++++++++++++++++------------------------------------ Cargo.toml | 6 ++++ 2 files changed, 34 insertions(+), 57 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b329d224..e078b0dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -133,8 +133,7 @@ dependencies = [ [[package]] name = "any_spawner" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1384d3fe1eecb464229fcf6eebb72306591c56bf27b373561489458a7c73027d" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "futures", "thiserror 2.0.16", @@ -926,8 +925,7 @@ dependencies = [ [[package]] name = "const_str_slice_concat" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67855af358fcb20fac58f9d714c94e2b228fe5694c1c9b4ead4a366343eda1b" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" [[package]] name = "convert_case" @@ -1402,8 +1400,7 @@ dependencies = [ [[package]] name = "either_of" version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216d23e0ec69759a17f05e1c553f3a6870e5ec73420fbb07807a6f34d5d1d5a4" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "paste", "pin-project-lite", @@ -2013,12 +2010,10 @@ checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" [[package]] name = "hydration_context" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8714ae4adeaa846d838f380fbd72f049197de629948f91bf045329e0cf0a283" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "futures", "js-sys", - "once_cell", "or_poisoned", "pin-project-lite", "serde", @@ -2480,8 +2475,7 @@ dependencies = [ [[package]] name = "leptos" version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a8710b4908a0e7b693113b906e4cf1bc87123b685404d090cdcd3e220bcab4" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "base64 0.22.1", @@ -2563,8 +2557,7 @@ dependencies = [ [[package]] name = "leptos_axum" version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba0d920d78828a8811bc52bdb25c7982d3c707f3497c3bdbb8a6c796d843a9c" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "axum 0.8.4", @@ -2587,8 +2580,7 @@ dependencies = [ [[package]] name = "leptos_config" version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240b4cb96284256a44872563cf029f24d6fe14bc341dcf0f4164e077cb5a1471" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "config", "regex", @@ -2600,8 +2592,7 @@ dependencies = [ [[package]] name = "leptos_dom" version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e920c8b2fd202b25786b0c72a00c745a6962fa923e600df6f3ec352d844be91" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "js-sys", "or_poisoned", @@ -2616,8 +2607,7 @@ dependencies = [ [[package]] name = "leptos_hot_reload" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d61ec3e1ff8aaee8c5151688550c0363f85bc37845450764c31ff7584a33f38" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "anyhow", "camino", @@ -2634,8 +2624,7 @@ dependencies = [ [[package]] name = "leptos_integration_utils" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea02f77bee8de1e9dd4c7ef1c401dd3a1afef8dab6e240af6f7d6f73403a259f" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "futures", "hydration_context", @@ -2649,8 +2638,7 @@ dependencies = [ [[package]] name = "leptos_macro" version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a84c7e53895c786f1128e91c36a708435e301f487338d19f2f6b5b67bb39ece2" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "attribute-derive", "cfg-if", @@ -2673,8 +2661,7 @@ dependencies = [ [[package]] name = "leptos_meta" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d489e38d3f541e9e43ecc2e3a815527840345a2afca629b3e23fcc1dd254578" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "futures", "indexmap 2.11.1", @@ -2688,8 +2675,7 @@ dependencies = [ [[package]] name = "leptos_router" version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13e0e0a70f40e4717da84415f6f1002091146ef247246b6a447d76947ab2e30" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "either_of", @@ -2713,8 +2699,7 @@ dependencies = [ [[package]] name = "leptos_router_macro" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "571042420d79f4f5b6b0d149dc1561b03f47e08c37c8fa0dfc80c73ad67be8af" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "proc-macro-error2", "proc-macro2", @@ -2725,8 +2710,7 @@ dependencies = [ [[package]] name = "leptos_server" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38acbf32649a4b127c8d4ccaed8fb388e19a746430a0ea8f8160e51e28c36e2d" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "base64 0.22.1", @@ -3060,8 +3044,7 @@ dependencies = [ [[package]] name = "next_tuple" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60993920e071b0c9b66f14e2b32740a4e27ffc82854dcd72035887f336a09a28" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" [[package]] name = "nix-compat" @@ -3280,8 +3263,7 @@ dependencies = [ [[package]] name = "oco_ref" version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0423ff9973dea4d6bd075934fdda86ebb8c05bdf9d6b0507067d4a1226371d" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "serde", "thiserror 2.0.16", @@ -3308,8 +3290,7 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "or_poisoned" version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c04f5d74368e4d0dfe06c45c8627c81bd7c317d52762d118fb9b3076f6420fd" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" [[package]] name = "outref" @@ -3961,8 +3942,7 @@ dependencies = [ [[package]] name = "reactive_graph" version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27e4f808d01701256dc220e398d518684781bcd1b3b1a6c1c107fd41374f0624" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "async-lock", @@ -3985,8 +3965,7 @@ dependencies = [ [[package]] name = "reactive_stores" version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79983e88dfd1a2925e29a4853ab9161b234ea78dd0d44ed33a706c9cd5e35762" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "dashmap 6.1.0", "guardian", @@ -4002,8 +3981,7 @@ dependencies = [ [[package]] name = "reactive_stores_macro" version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa40919eb2975100283b2a70e68eafce1e8bcf81f0622ff168e4c2b3f8d46bb" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "convert_case 0.8.0", "proc-macro-error2", @@ -4492,8 +4470,7 @@ dependencies = [ [[package]] name = "server_fn" version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4efa7bb741386fb31a68269c81b1469c917d9adb1f4102a2d2684f11e3235389" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "axum 0.8.4", "base64 0.22.1", @@ -4532,8 +4509,7 @@ dependencies = [ [[package]] name = "server_fn_macro" version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d1a916793571234d1c4622153d42495d26605ed7b9d5d38a2699666cfef46b3" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "const_format", "convert_case 0.8.0", @@ -4547,8 +4523,7 @@ dependencies = [ [[package]] name = "server_fn_macro_default" version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63eb08f80db903d3c42f64e60ebb3875e0305be502bdc064ec0a0eab42207f00" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "server_fn_macro", "syn 2.0.106", @@ -5096,8 +5071,7 @@ dependencies = [ [[package]] name = "tachys" version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dacbb26ffb2bbe6743702ee27c3e994c0caae86c92137278de9a9d92d383765c" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "any_spawner", "async-trait", @@ -5234,8 +5208,7 @@ dependencies = [ [[package]] name = "throw_error" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41e42a6afdde94f3e656fae18f837cb9bbe500a5ac5de325b09f3ec05b9c28e3" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "pin-project-lite", ] @@ -6094,8 +6067,7 @@ dependencies = [ [[package]] name = "wasm_split_helpers" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c50e0e45d0d871605a21fc4ee93a5380b7bdc41b5eda22e42f0777a4ce79b65c" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "async-once-cell", "or_poisoned", @@ -6105,8 +6077,7 @@ dependencies = [ [[package]] name = "wasm_split_macros" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8a7f0bf54b0129a337aadfe8b716d843689f69c75b2a6413a0cff2e0d00982" +source = "git+https://github.com/johnbchron/leptos.git#49b902ed472e73942fc259c9bd9cfccbaadf7072" dependencies = [ "base16", "digest", diff --git a/Cargo.toml b/Cargo.toml index 19dd5a16..af9b3021 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,12 @@ leptos_router = { version = "0.8", features = [ "nightly" ] } console_error_panic_hook = "0.1" wasm-bindgen = "=0.2.100" +[patch.crates-io] +leptos = { git = 'https://github.com/johnbchron/leptos.git' } +leptos_axum = { git = 'https://github.com/johnbchron/leptos.git' } +leptos_meta = { git = 'https://github.com/johnbchron/leptos.git' } +leptos_router = { git = 'https://github.com/johnbchron/leptos.git' } + [profile.wasm-release] codegen-units = 1 inherits = "release" From 6171c852880af6eb22d7acc0eef0f50ec0680e4d Mon Sep 17 00:00:00 2001 From: John Lewis Date: Wed, 17 Sep 2025 16:55:33 -0700 Subject: [PATCH 4/4] fix(app): repair next_url machinery --- crates/site-app/src/components/navbar.rs | 4 ++-- crates/site-app/src/hooks/login_hook.rs | 10 +++++--- crates/site-app/src/hooks/signup_hook.rs | 10 +++++--- crates/site-app/src/navigation.rs | 30 ++++++++++++++++++------ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/crates/site-app/src/components/navbar.rs b/crates/site-app/src/components/navbar.rs index 941c98e5..46cfcd62 100644 --- a/crates/site-app/src/components/navbar.rs +++ b/crates/site-app/src/components/navbar.rs @@ -4,7 +4,7 @@ use leptos::{either::Either, prelude::*}; use models::AuthUser; use self::org_selector::OrgSelectorPopover; -use crate::{hooks::OrgHook, navigation::next_url_hook}; +use crate::{hooks::OrgHook, navigation::next_url_encoded_hook}; #[component] pub fn Navbar() -> impl IntoView { @@ -46,7 +46,7 @@ fn NavbarUserArea() -> impl IntoView { #[component] fn LoggedOutUserAuthActions() -> impl IntoView { - let next_url = next_url_hook(); + let next_url = next_url_encoded_hook(); let signup_url = Signal::derive(move || format!("/auth/signup?next={}", next_url())); let login_url = diff --git a/crates/site-app/src/hooks/login_hook.rs b/crates/site-app/src/hooks/login_hook.rs index f0364984..4da647dd 100644 --- a/crates/site-app/src/hooks/login_hook.rs +++ b/crates/site-app/src/hooks/login_hook.rs @@ -4,7 +4,7 @@ use leptos::{ev::Event, prelude::*}; use models::dvf::{EmailAddress, EmailAddressError}; use crate::{ - navigation::{navigate_to, next_url_hook}, + navigation::{navigate_to, next_url_string_hook}, reactive_utils::touched_input_bindings, }; @@ -13,7 +13,7 @@ pub struct LoginHook { email_signal: RwSignal, password_signal: RwSignal, submit_touched_signal: RwSignal, - next_url_memo: Memo, + next_url_memo: Signal, action: Action<(), Result>, } @@ -22,7 +22,7 @@ impl LoginHook { let email_signal = RwSignal::new(String::new()); let password_signal = RwSignal::new(String::new()); let submit_touched_signal = RwSignal::new(false); - let next_url_memo = next_url_hook(); + let next_url_memo = next_url_string_hook(); let action = Action::new_local(move |(): &()| { // json body for authenticate endpoint @@ -140,6 +140,10 @@ impl LoginHook { pub fn create_redirect_effect(&self) -> Effect { let (action, next_url_memo) = (self.action, self.next_url_memo); Effect::new(move || { + leptos::logging::log!( + "redirect effect set to navigate to {:?}", + next_url_memo() + ); if action.value().get() == Some(Ok(true)) { navigate_to(&next_url_memo()); } diff --git a/crates/site-app/src/hooks/signup_hook.rs b/crates/site-app/src/hooks/signup_hook.rs index a3f4b61d..67f6d9dd 100644 --- a/crates/site-app/src/hooks/signup_hook.rs +++ b/crates/site-app/src/hooks/signup_hook.rs @@ -4,7 +4,7 @@ use leptos::{ev::Event, prelude::*}; use models::dvf::{EmailAddress, EmailAddressError, HumanName, HumanNameError}; use crate::{ - navigation::{navigate_to, next_url_hook}, + navigation::{navigate_to, next_url_string_hook}, reactive_utils::touched_input_bindings, }; @@ -14,7 +14,7 @@ pub struct SignupHook { password_signal: RwSignal, confirm_password_signal: RwSignal, submit_touched_signal: RwSignal, - next_url_memo: Memo, + next_url_memo: Signal, action: Action<(), Result>, } @@ -25,7 +25,7 @@ impl SignupHook { let password_signal = RwSignal::new(String::new()); let confirm_password_signal = RwSignal::new(String::new()); let submit_touched_signal = RwSignal::new(false); - let next_url_memo = next_url_hook(); + let next_url_memo = next_url_string_hook(); let action = Action::new_local(move |(): &()| { // json body for authenticate endpoint @@ -203,6 +203,10 @@ impl SignupHook { pub fn create_redirect_effect(&self) -> Effect { let (action, next_url_memo) = (self.action, self.next_url_memo); + leptos::logging::log!( + "redirect effect set to navigate to {:?}", + next_url_memo() + ); Effect::new(move || { if action.value().get() == Some(Ok(true)) { navigate_to(&next_url_memo()); diff --git a/crates/site-app/src/navigation.rs b/crates/site-app/src/navigation.rs index 8eb1f07c..36a0245d 100644 --- a/crates/site-app/src/navigation.rs +++ b/crates/site-app/src/navigation.rs @@ -46,18 +46,34 @@ pub fn navigate_to(path: &str) { } /// Gets the next URL if it's already set or sets it to the current page. -#[allow(unused_variables)] -pub fn next_url_hook() -> Memo { +pub fn next_url_string_hook() -> Signal { + #[cfg(not(feature = "ssr"))] + use leptos_router::location::LocationProvider; + #[cfg(feature = "ssr")] let current_url = leptos_router::hooks::use_url()(); - #[cfg(feature = "hydrate")] - let current_url = ::current().unwrap(); + #[cfg(not(feature = "ssr"))] + let current_url = leptos_router::location::BrowserUrl::current() + .expect("failed to get current browser url"); + + leptos::logging::log!("current_url = {current_url:?}"); - // set it to the existing next url or the current URL escaped - Memo::new(move |_| { + Signal::stored( current_url .search_params() + .clone() .get("next") - .unwrap_or(Url::escape(&url_to_full_path(¤t_url))) + .unwrap_or(url_to_full_path(¤t_url)), + ) +} + +/// Url-enccodes the next URL if it's already set or sets it to the current +/// page. Suitable for propagating the next URL by setting the param to this +/// value in links. +pub fn next_url_encoded_hook() -> Signal { + let next_url = next_url_string_hook(); + Signal::derive(move || { + let next_url = next_url(); + Url::escape(&next_url) }) }