mirror of
https://github.com/Nutomic/ibis.git
synced 2025-02-03 18:21:35 +00:00
Simplify code for explore page
This commit is contained in:
parent
c330061087
commit
c588e71e60
3 changed files with 30 additions and 40 deletions
|
@ -1,37 +0,0 @@
|
||||||
use crate::frontend::{api::CLIENT, utils::errors::FrontendResultExt};
|
|
||||||
use codee::{Decoder, Encoder};
|
|
||||||
use leptos::prelude::*;
|
|
||||||
use std::fmt::Debug;
|
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn ConnectView<T, R>(res: Resource<T, R>) -> impl IntoView
|
|
||||||
where
|
|
||||||
T: Clone + Send + Sync + 'static,
|
|
||||||
R: Encoder<T> + Decoder<T> + Send + Sync + 'static,
|
|
||||||
<R as Encoder<T>>::Error: Debug,
|
|
||||||
<R as Encoder<T>>::Encoded: IntoEncodedString,
|
|
||||||
<R as Decoder<T>>::Encoded: FromEncodedStr,
|
|
||||||
<R as Decoder<T>>::Error: Debug,
|
|
||||||
<<R as Decoder<T>>::Encoded as leptos::prelude::FromEncodedStr>::DecodingError: Debug,
|
|
||||||
{
|
|
||||||
let connect_ibis_wiki = Action::new(move |_: &()| async move {
|
|
||||||
CLIENT
|
|
||||||
.resolve_instance(Url::parse("https://ibis.wiki").expect("parse ibis.wiki url"))
|
|
||||||
.await
|
|
||||||
.error_popup(|_| res.refetch());
|
|
||||||
});
|
|
||||||
|
|
||||||
view! {
|
|
||||||
<div class="flex justify-center h-screen">
|
|
||||||
<button
|
|
||||||
class="place-self-center btn btn-primary"
|
|
||||||
on:click=move |_| {
|
|
||||||
connect_ibis_wiki.dispatch(());
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Connect with ibis.wiki
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,6 @@ pub mod article_editor;
|
||||||
pub mod article_nav;
|
pub mod article_nav;
|
||||||
pub mod comment;
|
pub mod comment;
|
||||||
pub mod comment_editor;
|
pub mod comment_editor;
|
||||||
pub mod connect;
|
|
||||||
pub mod credentials;
|
pub mod credentials;
|
||||||
pub mod edit_list;
|
pub mod edit_list;
|
||||||
pub mod instance_follow_button;
|
pub mod instance_follow_button;
|
||||||
|
|
|
@ -2,12 +2,17 @@ use crate::{
|
||||||
common::instance::DbInstance,
|
common::instance::DbInstance,
|
||||||
frontend::{
|
frontend::{
|
||||||
api::CLIENT,
|
api::CLIENT,
|
||||||
components::{connect::ConnectView, suspense_error::SuspenseError},
|
components::suspense_error::SuspenseError,
|
||||||
utils::formatting::{instance_title_with_domain, instance_updated},
|
utils::{
|
||||||
|
errors::{FrontendResult, FrontendResultExt},
|
||||||
|
formatting::{instance_title_with_domain, instance_updated},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use codee::string::JsonSerdeCodec;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_meta::Title;
|
use leptos_meta::Title;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Explore() -> impl IntoView {
|
pub fn Explore() -> impl IntoView {
|
||||||
|
@ -58,3 +63,26 @@ pub fn instance_card(i: &DbInstance) -> impl IntoView {
|
||||||
</li>
|
</li>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
fn ConnectView(res: Resource<FrontendResult<Vec<DbInstance>>, JsonSerdeCodec>) -> impl IntoView {
|
||||||
|
let connect_ibis_wiki = Action::new(move |_: &()| async move {
|
||||||
|
CLIENT
|
||||||
|
.resolve_instance(Url::parse("https://ibis.wiki").expect("parse ibis.wiki url"))
|
||||||
|
.await
|
||||||
|
.error_popup(|_| res.refetch());
|
||||||
|
});
|
||||||
|
|
||||||
|
view! {
|
||||||
|
<div class="flex justify-center h-screen">
|
||||||
|
<button
|
||||||
|
class="place-self-center btn btn-primary"
|
||||||
|
on:click=move |_| {
|
||||||
|
connect_ibis_wiki.dispatch(());
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Connect with ibis.wiki
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue