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

View file

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