From 0304c5cb7dd49c8affebe6aa4b209a4aba340f75 Mon Sep 17 00:00:00 2001 From: spinline Date: Mon, 9 Feb 2026 22:32:19 +0300 Subject: [PATCH] fix: prevent panic by using signals for redirects and fix auth flow --- frontend/src/app.rs | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/frontend/src/app.rs b/frontend/src/app.rs index 9c860de..9846e04 100644 --- a/frontend/src/app.rs +++ b/frontend/src/app.rs @@ -15,6 +15,8 @@ pub fn App() -> impl IntoView { let is_loading = signal(true); let is_authenticated = signal(false); + let needs_auth_redirect = signal(false); + let needs_setup_redirect = signal(false); Effect::new(move |_| { spawn_local(async move { @@ -26,7 +28,8 @@ pub fn App() -> impl IntoView { Ok(status) => { if !status.completed { log::info!("Setup not completed, redirecting to /setup"); - is_loading.1.set(false); + needs_setup_redirect.set(true); + is_loading.set(false); return; } } @@ -45,22 +48,24 @@ pub fn App() -> impl IntoView { } } - is_authenticated.1.set(true); + is_authenticated.set(true); } Ok(false) => { log::info!("Not authenticated"); + needs_auth_redirect.set(true); } Err(e) => { log::error!("Auth check failed: {:?}", e); + needs_auth_redirect.set(true); } } - is_loading.1.set(false); + is_loading.set(false); }); }); Effect::new(move |_| { - if is_authenticated.0.get() { + if is_authenticated.get() { spawn_local(async { gloo_timers::future::TimeoutFuture::new(2000).await; @@ -76,12 +81,12 @@ pub fn App() -> impl IntoView { "404 Not Found" }> impl IntoView { view! { } } /> impl IntoView { } /> }> - + @@ -126,17 +129,16 @@ pub fn App() -> impl IntoView { }/> - + +
"Settings Page (Coming Soon)"