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 { } /> - + } } 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 || {