fix: use .0 for reading and .1 for writing signals
All checks were successful
Build MIPS Binary / build (push) Successful in 5m20s
All checks were successful
Build MIPS Binary / build (push) Successful in 5m20s
This commit is contained in:
@@ -15,8 +15,6 @@ pub fn App() -> impl IntoView {
|
|||||||
|
|
||||||
let is_loading = signal(true);
|
let is_loading = signal(true);
|
||||||
let is_authenticated = signal(false);
|
let is_authenticated = signal(false);
|
||||||
let needs_auth_redirect = signal(false);
|
|
||||||
let needs_setup_redirect = signal(false);
|
|
||||||
|
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
spawn_local(async move {
|
spawn_local(async move {
|
||||||
@@ -27,9 +25,8 @@ pub fn App() -> impl IntoView {
|
|||||||
match setup_res {
|
match setup_res {
|
||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
if !status.completed {
|
if !status.completed {
|
||||||
log::info!("Setup not completed, redirecting to /setup");
|
log::info!("Setup not completed");
|
||||||
needs_setup_redirect.set(true);
|
is_loading.1.set(false);
|
||||||
is_loading.set(false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,24 +45,22 @@ pub fn App() -> impl IntoView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is_authenticated.set(true);
|
is_authenticated.1.set(true);
|
||||||
}
|
}
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
log::info!("Not authenticated");
|
log::info!("Not authenticated");
|
||||||
needs_auth_redirect.set(true);
|
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Auth check failed: {:?}", e);
|
log::error!("Auth check failed: {:?}", e);
|
||||||
needs_auth_redirect.set(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is_loading.set(false);
|
is_loading.1.set(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if is_authenticated.get() {
|
if is_authenticated.0.get() {
|
||||||
spawn_local(async {
|
spawn_local(async {
|
||||||
gloo_timers::future::TimeoutFuture::new(2000).await;
|
gloo_timers::future::TimeoutFuture::new(2000).await;
|
||||||
|
|
||||||
@@ -81,7 +76,7 @@ pub fn App() -> impl IntoView {
|
|||||||
<Router>
|
<Router>
|
||||||
<Routes fallback=|| view! { <div class="p-4">"404 Not Found"</div> }>
|
<Routes fallback=|| view! { <div class="p-4">"404 Not Found"</div> }>
|
||||||
<Route path=leptos_router::path!("/login") view=move || {
|
<Route path=leptos_router::path!("/login") view=move || {
|
||||||
let authenticated = is_authenticated.get();
|
let authenticated = is_authenticated.0.get();
|
||||||
|
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if authenticated {
|
if authenticated {
|
||||||
@@ -95,7 +90,7 @@ pub fn App() -> impl IntoView {
|
|||||||
} />
|
} />
|
||||||
<Route path=leptos_router::path!("/setup") view=move || {
|
<Route path=leptos_router::path!("/setup") view=move || {
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if is_authenticated.get() {
|
if is_authenticated.0.get() {
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/", Default::default());
|
navigate("/", Default::default());
|
||||||
}
|
}
|
||||||
@@ -106,7 +101,7 @@ pub fn App() -> impl IntoView {
|
|||||||
|
|
||||||
<Route path=leptos_router::path!("/") view=move || {
|
<Route path=leptos_router::path!("/") view=move || {
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if !is_loading.get() && !is_authenticated.get() {
|
if !is_loading.0.get() && !is_authenticated.0.get() {
|
||||||
log::info!("Not authenticated, redirecting to login");
|
log::info!("Not authenticated, redirecting to login");
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/login", Default::default());
|
navigate("/login", Default::default());
|
||||||
@@ -114,12 +109,12 @@ pub fn App() -> impl IntoView {
|
|||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<Show when=move || !is_loading.get() fallback=|| view! {
|
<Show when=move || !is_loading.0.get() fallback=|| view! {
|
||||||
<div class="flex items-center justify-center h-screen bg-base-100">
|
<div class="flex items-center justify-center h-screen bg-base-100">
|
||||||
<span class="loading loading-spinner loading-lg"></span>
|
<span class="loading loading-spinner loading-lg"></span>
|
||||||
</div>
|
</div>
|
||||||
}>
|
}>
|
||||||
<Show when=move || is_authenticated.get() fallback=|| ()>
|
<Show when=move || is_authenticated.0.get() fallback=|| ()>
|
||||||
<Protected>
|
<Protected>
|
||||||
<TorrentTable />
|
<TorrentTable />
|
||||||
</Protected>
|
</Protected>
|
||||||
@@ -130,15 +125,15 @@ pub fn App() -> impl IntoView {
|
|||||||
|
|
||||||
<Route path=leptos_router::path!("/settings") view=move || {
|
<Route path=leptos_router::path!("/settings") view=move || {
|
||||||
Effect::new(move |_| {
|
Effect::new(move |_| {
|
||||||
if !is_authenticated.get() {
|
if !is_authenticated.0.get() {
|
||||||
let navigate = use_navigate();
|
let navigate = use_navigate();
|
||||||
navigate("/login", Default::default());
|
navigate("/login", Default::default());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<Show when=move || !is_loading.get() fallback=|| ()>
|
<Show when=move || !is_loading.0.get() fallback=|| ()>
|
||||||
<Show when=move || is_authenticated.get() fallback=|| ()>
|
<Show when=move || is_authenticated.0.get() fallback=|| ()>
|
||||||
<Protected>
|
<Protected>
|
||||||
<div class="p-4">"Settings Page (Coming Soon)"</div>
|
<div class="p-4">"Settings Page (Coming Soon)"</div>
|
||||||
</Protected>
|
</Protected>
|
||||||
|
|||||||
Reference in New Issue
Block a user