fix: upgrade to leptos 0.8 with compatible deps
Some checks failed
Build MIPS Binary / build (push) Failing after 1m28s
Some checks failed
Build MIPS Binary / build (push) Failing after 1m28s
- Update leptos-use from 0.15 to 0.16 for reactive_graph compatibility - Fix web-sys ProgressElement -> ProgressEvent feature - Resolve closure ownership issues in context_menu.rs and statusbar.rs - Update Cargo dependencies for stable compilation
This commit is contained in:
@@ -5,43 +5,41 @@ use crate::components::auth::login::Login;
|
||||
use crate::components::auth::setup::Setup;
|
||||
use crate::api;
|
||||
use leptos::prelude::*;
|
||||
use leptos::logging;
|
||||
use leptos::task::spawn_local;
|
||||
use leptos_router::components::{Router, Routes, Route};
|
||||
use leptos_router::hooks::use_navigate;
|
||||
// use leptos_router::PossibleRouteMatch; // Bu trait prelude ile gelmeli veya public olmayabilir.
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
crate::store::provide_torrent_store();
|
||||
|
||||
let (is_loading, set_is_loading) = create_signal(true);
|
||||
let (is_authenticated, set_is_authenticated) = create_signal(false);
|
||||
let is_loading = signal(true);
|
||||
let is_authenticated = signal(false);
|
||||
|
||||
create_effect(move |_| {
|
||||
Effect::new(move |_| {
|
||||
spawn_local(async move {
|
||||
logging::log!("App initialization started...");
|
||||
log::info!("App initialization started...");
|
||||
|
||||
let setup_res = api::setup::get_status().await;
|
||||
|
||||
match setup_res {
|
||||
Ok(status) => {
|
||||
if !status.completed {
|
||||
logging::log!("Setup not completed, redirecting to /setup");
|
||||
log::info!("Setup not completed, redirecting to /setup");
|
||||
let navigate = use_navigate();
|
||||
navigate("/setup", Default::default());
|
||||
set_is_loading.set(false);
|
||||
is_loading.1.set(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Err(e) => logging::error!("Failed to get setup status: {:?}", e),
|
||||
Err(e) => log::error!("Failed to get setup status: {:?}", e),
|
||||
}
|
||||
|
||||
let auth_res = api::auth::check_auth().await;
|
||||
|
||||
match auth_res {
|
||||
Ok(true) => {
|
||||
logging::log!("Authenticated!");
|
||||
log::info!("Authenticated!");
|
||||
|
||||
if let Ok(user_info) = api::auth::get_user().await {
|
||||
if let Some(store) = use_context::<crate::store::TorrentStore>() {
|
||||
@@ -49,17 +47,17 @@ pub fn App() -> impl IntoView {
|
||||
}
|
||||
}
|
||||
|
||||
set_is_authenticated.set(true);
|
||||
is_authenticated.1.set(true);
|
||||
|
||||
let pathname = window().location().pathname().unwrap_or_default();
|
||||
if pathname == "/login" || pathname == "/setup" {
|
||||
logging::log!("Already authenticated, redirecting to home");
|
||||
log::info!("Already authenticated, redirecting to home");
|
||||
let navigate = use_navigate();
|
||||
navigate("/", Default::default());
|
||||
}
|
||||
}
|
||||
Ok(false) => {
|
||||
logging::log!("Not authenticated");
|
||||
log::info!("Not authenticated");
|
||||
|
||||
let pathname = window().location().pathname().unwrap_or_default();
|
||||
if pathname != "/login" && pathname != "/setup" {
|
||||
@@ -68,18 +66,18 @@ pub fn App() -> impl IntoView {
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
logging::error!("Auth check failed: {:?}", e);
|
||||
log::error!("Auth check failed: {:?}", e);
|
||||
let navigate = use_navigate();
|
||||
navigate("/login", Default::default());
|
||||
}
|
||||
}
|
||||
|
||||
set_is_loading.set(false);
|
||||
is_loading.1.set(false);
|
||||
});
|
||||
});
|
||||
|
||||
create_effect(move |_| {
|
||||
if is_authenticated.get() {
|
||||
Effect::new(move |_| {
|
||||
if is_authenticated.0.get() {
|
||||
spawn_local(async {
|
||||
gloo_timers::future::TimeoutFuture::new(2000).await;
|
||||
|
||||
@@ -93,18 +91,18 @@ pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
<div class="relative w-full h-screen" style="height: 100dvh;">
|
||||
<Router>
|
||||
<Routes fallback=|| view! { "404 Not Found" }>
|
||||
<Route path="/login" view=move || view! { <Login /> } />
|
||||
<Route path="/setup" view=move || view! { <Setup /> } />
|
||||
<Routes fallback=|| view! { <div class="p-4">"404 Not Found"</div> }>
|
||||
<Route path=leptos_router::path!("/login") view=move || view! { <Login /> } />
|
||||
<Route path=leptos_router::path!("/setup") view=move || view! { <Setup /> } />
|
||||
|
||||
<Route path="/" view=move || {
|
||||
<Route path=leptos_router::path!("/") view=move || {
|
||||
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">
|
||||
<span class="loading loading-spinner loading-lg"></span>
|
||||
</div>
|
||||
}>
|
||||
<Show when=move || is_authenticated.get() fallback=|| ()>
|
||||
<Show when=move || is_authenticated.0.get() fallback=|| ()>
|
||||
<Protected>
|
||||
<TorrentTable />
|
||||
</Protected>
|
||||
@@ -113,10 +111,10 @@ pub fn App() -> impl IntoView {
|
||||
}
|
||||
}/>
|
||||
|
||||
<Route path="/settings" view=move || {
|
||||
<Route path=leptos_router::path!("/settings") view=move || {
|
||||
view! {
|
||||
<Show when=move || !is_loading.get() fallback=|| ()>
|
||||
<Show when=move || is_authenticated.get() fallback=|| ()>
|
||||
<Show when=move || !is_loading.0.get() fallback=|| ()>
|
||||
<Show when=move || is_authenticated.0.get() fallback=|| ()>
|
||||
<Protected>
|
||||
<div class="p-4">"Settings Page (Coming Soon)"</div>
|
||||
</Protected>
|
||||
@@ -130,4 +128,4 @@ pub fn App() -> impl IntoView {
|
||||
<ToastContainer />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user