From a099181085ca09766eab08e9a08ff8889d572f02 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 11 Nov 2024 11:41:28 +0100 Subject: [PATCH] Also show connect button on article page --- src/frontend/components/connect.rs | 25 ++++++++++++++++ src/frontend/components/mod.rs | 1 + src/frontend/pages/article/list.rs | 45 ++++++++++++++++------------- src/frontend/pages/instance/list.rs | 25 ++-------------- 4 files changed, 53 insertions(+), 43 deletions(-) create mode 100644 src/frontend/components/connect.rs diff --git a/src/frontend/components/connect.rs b/src/frontend/components/connect.rs new file mode 100644 index 0000000..fc28d96 --- /dev/null +++ b/src/frontend/components/connect.rs @@ -0,0 +1,25 @@ +use crate::frontend::app::GlobalState; +use leptos::{component, *}; +use url::Url; + +#[component] +pub fn ConnectView(res: Resource) -> impl IntoView { + let connect_ibis_wiki = create_action(move |_: &()| async move { + GlobalState::api_client() + .resolve_instance(Url::parse("https://ibis.wiki").unwrap()) + .await + .unwrap(); + res.refetch(); + }); + + view! { +
+ +
+ } +} diff --git a/src/frontend/components/mod.rs b/src/frontend/components/mod.rs index fa9f556..c8e65ae 100644 --- a/src/frontend/components/mod.rs +++ b/src/frontend/components/mod.rs @@ -1,4 +1,5 @@ pub mod article_nav; +pub mod connect; pub mod credentials; pub mod editor; pub mod instance_follow_button; diff --git a/src/frontend/pages/article/list.rs b/src/frontend/pages/article/list.rs index 6bf2aea..5daccb0 100644 --- a/src/frontend/pages/article/list.rs +++ b/src/frontend/pages/article/list.rs @@ -1,6 +1,6 @@ use crate::{ common::ListArticlesForm, - frontend::{app::GlobalState, article_link, article_title}, + frontend::{app::GlobalState, article_link, article_title, components::connect::ConnectView}, }; use html::Input; use leptos::*; @@ -50,26 +50,31 @@ pub fn ListArticles() -> impl IntoView { } /> -
    - {move || { - articles - .get() - .map(|a| { - a.into_iter() - .map(|a| { - view! { -
  • - - {article_title(&a)} - -
  • - } - }) - .collect::>() - }) - }} + 1 || only_local.get() } + fallback=move || view! { } + > +
      + {move || { + articles + .get() + .map(|a| { + a.into_iter() + .map(|a| { + view! { +
    • + + {article_title(&a)} + +
    • + } + }) + .collect::>() + }) + }} -
    +
+ } } diff --git a/src/frontend/pages/instance/list.rs b/src/frontend/pages/instance/list.rs index 23b27a8..2d657ff 100644 --- a/src/frontend/pages/instance/list.rs +++ b/src/frontend/pages/instance/list.rs @@ -1,6 +1,5 @@ -use crate::frontend::app::GlobalState; +use crate::frontend::{app::GlobalState, components::connect::ConnectView}; use leptos::*; -use url::Url; #[component] pub fn ListInstances() -> impl IntoView { @@ -9,32 +8,12 @@ pub fn ListInstances() -> impl IntoView { |_| async move { GlobalState::api_client().list_instances().await.unwrap() }, ); - let connect_ibis_wiki = create_action(move |_: &()| async move { - GlobalState::api_client() - .resolve_instance(Url::parse("https://ibis.wiki").unwrap()) - .await - .unwrap(); - instances.refetch(); - }); - let fallback = move || { - view! { -
- -
- } - }; - view! {

Instances

} >
    {move || {