cargo clippy

This commit is contained in:
rick 2022-10-30 17:14:09 +01:00
parent e1d720f5d6
commit 974c75b9b6
Signed by: Rick
GPG key ID: 4A6223D66294EB20
2 changed files with 9 additions and 13 deletions

View file

@ -11,19 +11,19 @@ pub struct Home {
user: Option<User>, user: Option<User>,
} }
#[derive(PartialEq)] #[derive(Eq, PartialEq)]
pub enum TestMessage { pub enum TestMessage {
Toast(ToastType), Toast(ToastType),
ConnexionOk(User), ConnexionOk(User),
} }
#[derive(PartialEq)] #[derive(Eq, PartialEq)]
pub struct ToastFields { pub struct ToastFields {
pub title: String, pub title: String,
pub body: String, pub body: String,
} }
#[derive(PartialEq)] #[derive(Eq, PartialEq)]
pub enum ToastType { pub enum ToastType {
Info(ToastFields), Info(ToastFields),
Error(ToastFields), Error(ToastFields),
@ -40,7 +40,7 @@ impl Component for Home {
fn view(&self, ctx: &Context<Self>) -> Html { fn view(&self, ctx: &Context<Self>) -> Html {
let user: Result<User, StorageError> = LocalStorage::get("auth"); let user: Result<User, StorageError> = LocalStorage::get("auth");
if let Ok(user) = user { if let Ok(user) = user {
if let None = self.user { if self.user.is_none() {
ctx.link().send_message(TestMessage::ConnexionOk(user)); ctx.link().send_message(TestMessage::ConnexionOk(user));
} }
} else { } else {
@ -62,7 +62,7 @@ impl Component for Home {
], ],
Err(err) => vec![TestMessage::Toast(ToastType::Error( Err(err) => vec![TestMessage::Toast(ToastType::Error(
ToastFields { ToastFields {
title: String::from("Error from the promise"), title: String::from("Erreur lors de l'ajout du token dans le LocalStorage."),
body: err.to_string(), body: err.to_string(),
}, },
))], ))],
@ -71,7 +71,7 @@ impl Component for Home {
Err(err) => { Err(err) => {
LocalStorage::delete("auth"); LocalStorage::delete("auth");
vec![TestMessage::Toast(ToastType::Error(ToastFields { vec![TestMessage::Toast(ToastType::Error(ToastFields {
title: String::from("Error from the promise"), title: String::from("Connexion: JSON non valide."),
body: err.to_string(), body: err.to_string(),
}))] }))]
} }
@ -84,15 +84,13 @@ impl Component for Home {
} }
} }
Err(err) => vec![TestMessage::Toast(ToastType::Error(ToastFields { Err(err) => vec![TestMessage::Toast(ToastType::Error(ToastFields {
title: String::from("Error from the promise"), title: String::from("Connexion: Erreur lors de la tentative de la connexion."),
body: err.to_string(), body: err.to_string(),
}))], }))],
} }
}); });
} }
//let onclick = ctx.link().callback(|_| TestMessage::Test);
html! { html! {
<> <>
<ToastViewer /> <ToastViewer />
@ -112,7 +110,6 @@ impl Component for Home {
<p><a href="/login/discord">{ "SE CONNECTER VIA DISCORD ICI" }</a></p> <p><a href="/login/discord">{ "SE CONNECTER VIA DISCORD ICI" }</a></p>
<p><a href="/login/steam">{ "SE CONNECTER VIA STEAM ICI" }</a></p> <p><a href="/login/steam">{ "SE CONNECTER VIA STEAM ICI" }</a></p>
} }
//<button {onclick}>{"test"}</button>
</> </>
} }
} }
@ -136,7 +133,6 @@ impl Component for Home {
..Default::default() ..Default::default()
}), }),
}, },
//_ => ToastDispatcher::new().toast(html! {<Alert title="Coucou"></Alert>}),
_ => ToastDispatcher::new().toast(Toast { _ => ToastDispatcher::new().toast(Toast {
title: String::from("Un callback n'a pas été implémenté !"), title: String::from("Un callback n'a pas été implémenté !"),
r#type: Type::Warning, r#type: Type::Warning,

View file

@ -8,7 +8,7 @@ use gloo_net::http::Request;
use gloo_net::Error; use gloo_net::Error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Deserialize, PartialEq, Serialize)] #[derive(Clone, Deserialize, Eq, PartialEq, Serialize)]
pub struct User { pub struct User {
id: String, id: String,
banned: bool, banned: bool,
@ -27,7 +27,7 @@ struct Game {
name: String, name: String,
} }
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] #[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Group { pub struct Group {
pub id: String, pub id: String,
pub name: String, pub name: String,