From 7e288b3a820f2a2e2a40682f3c3cc69ebae023fe Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 25 Feb 2025 19:59:52 +0300 Subject: [PATCH] fix(url): fix url routing --- src/app.rs | 44 ++++++++++++++++++------------------ src/components/items_list.rs | 1 + 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/app.rs b/src/app.rs index 367b918..7a13fad 100644 --- a/src/app.rs +++ b/src/app.rs @@ -31,31 +31,31 @@ pub fn App() -> impl IntoView { view! { - { - set_items.set(loaded_items); - } - Err(err) => log!("Error loading items: {}", err), + // Proper async handling + spawn_local({ + let current_url = current_url.clone(); + async move { + match load_items_from_db(¤t_url()).await { + Ok(items) => set_items.set(items), + Err(e) => log!("Error loading items: {}", e), } - }); - }); - view! { - - -
-

{ "CompareWare" }

- -
} + }); + view! { + + +
+

{ "CompareWare" }

+ +
+ } }/>
diff --git a/src/components/items_list.rs b/src/components/items_list.rs index 03cb121..4711230 100644 --- a/src/components/items_list.rs +++ b/src/components/items_list.rs @@ -66,6 +66,7 @@ pub async fn load_items_from_db(current_url: &str) -> Result, String> #[component] pub fn ItemsList( + url: String, items: ReadSignal>, set_items: WriteSignal>, ) -> impl IntoView {