From b167d6d586e16d55cdcebe7d82a3ffaecdc0235b Mon Sep 17 00:00:00 2001 From: Zynh Ludwig Date: Fri, 30 Aug 2024 23:23:13 -0700 Subject: [PATCH] mass view refactoring --- src/main.rs | 4 ++-- src/router/link.rs | 2 +- src/router/records.rs | 41 +++++++++++++++++++++-------------------- src/views/base_page.rs | 2 +- src/views/links.rs | 4 ++-- src/views/welcome.rs | 2 +- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/main.rs b/src/main.rs index de9208e..a3ae66e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,9 +51,9 @@ async fn main() -> io::Result<()> { } async fn welcome() -> impl IntoResponse { - let cat_fact = views::get_cat_fact().await; + let fact = views::get_cat_fact().await; Html(ssr::render(move || { - leptos::view! { } + leptos::view! { } })) } diff --git a/src/router/link.rs b/src/router/link.rs index 72c081b..64b3494 100644 --- a/src/router/link.rs +++ b/src/router/link.rs @@ -28,7 +28,7 @@ async fn link( { return Ok(Html(ssr::render({ let record = record.clone(); - || leptos::view! { } + || leptos::view! { } }))); } } diff --git a/src/router/records.rs b/src/router/records.rs index 4ca4f6a..9d3338a 100644 --- a/src/router/records.rs +++ b/src/router/records.rs @@ -23,31 +23,32 @@ pub(crate) async fn records(State(state): State) -> impl IntoResponse // this behind some kind of authentication pub async fn records_links(State(state): State) -> impl IntoResponse { let records = state.records.lock().await.clone(); + + let records_list_view = records + .keys() + .map(|key| { + leptos::view! { + + } + }) + .collect_view(); + Html(ssr::render(move || { leptos::view! {
-
    - {records - .keys() - .map(|key| { - leptos::view! { - - } - }) - .collect_view()} -
+
    {records_list_view}
diff --git a/src/views/base_page.rs b/src/views/base_page.rs index 05ae275..56ce208 100644 --- a/src/views/base_page.rs +++ b/src/views/base_page.rs @@ -19,7 +19,7 @@ pub fn HtmxPage(children: Children) -> impl IntoView { -

NyaZoom2

+

"NyaZoom""2"

{children()} } diff --git a/src/views/links.rs b/src/views/links.rs index 2297c00..b26178e 100644 --- a/src/views/links.rs +++ b/src/views/links.rs @@ -24,7 +24,7 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView {
@@ -40,7 +40,7 @@ pub fn LinkView(id: String, record: UploadRecord) -> impl IntoView { - Return to home + "Return to home"
} diff --git a/src/views/welcome.rs b/src/views/welcome.rs index 0231f12..025c7b5 100644 --- a/src/views/welcome.rs +++ b/src/views/welcome.rs @@ -38,7 +38,7 @@ pub fn WelcomeView(fact: String) -> impl IntoView { data-multiple-caption="{{count}} files selected" multiple /> - +

{fact}