diff --git a/app/src/components/avatar.rs b/app/src/components/avatar.rs index f8ee8c5..c5ea1ab 100644 --- a/app/src/components/avatar.rs +++ b/app/src/components/avatar.rs @@ -1,6 +1,4 @@ -use crate::{ - components::avatar_cache::{AvatarCacheContext}, -}; +use crate::components::avatar_cache::AvatarCacheContext; use yew::{function_component, prelude::*}; #[derive(Properties, PartialEq)] @@ -13,7 +11,11 @@ pub struct Props { #[function_component(ShowAvatar)] pub fn show_avatar(props: &Props) -> Html { let cache = use_context::().expect("no ctx found"); - let avatar = cache.avatars.get(&props.username).map(|val| val.clone()).unwrap_or(None); + let avatar = cache + .avatars + .get(&props.username) + .map(|val| val.clone()) + .unwrap_or(None); match avatar { Some(avatar) => html! { )), } -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(PartialEq, Eq, Clone)] pub struct AvatarCache { pub avatars: HashMap>, } @@ -55,14 +55,14 @@ impl Reducible for AvatarCache { pub type AvatarCacheContext = UseReducerHandle; -#[derive(Debug, PartialEq, Clone)] +#[derive(PartialEq, Clone)] pub enum CacheMode { AllUsers, SingleUser(String), None, } -#[derive(Properties, Debug, PartialEq)] +#[derive(Properties, PartialEq)] pub struct AvatarCacheProviderProps { #[prop_or_default] pub children: Children, @@ -81,9 +81,7 @@ pub fn avatar_cache_provider(props: &AvatarCacheProviderProps) -> Html { use_effect_with_deps( move |mode| { match mode { - CacheMode::None => { - cache.dispatch(CacheAction::Clear) - } + CacheMode::None => cache.dispatch(CacheAction::Clear), CacheMode::AllUsers => { let cache = cache.clone(); wasm_bindgen_futures::spawn_local(async move { diff --git a/app/src/components/user_details_form.rs b/app/src/components/user_details_form.rs index e657376..b231026 100644 --- a/app/src/components/user_details_form.rs +++ b/app/src/components/user_details_form.rs @@ -13,8 +13,8 @@ use gloo_file::{ use graphql_client::GraphQLQuery; use validator_derive::Validate; use web_sys::{FileList, HtmlInputElement, InputEvent}; -use yew::prelude::*; use yew::context::ContextHandle; +use yew::prelude::*; use yew_form_derive::Model; #[derive(Default)] @@ -412,7 +412,10 @@ impl UserDetailsForm { self.user.avatar = Some(avatar); } self.just_updated = true; - self.avatar_cache.dispatch(CacheAction::AddAvatar((self.user.id.clone(), self.user.avatar.clone()))); + self.avatar_cache.dispatch(CacheAction::AddAvatar(( + self.user.id.clone(), + self.user.avatar.clone(), + ))); Ok(true) }