From da3874986f69df545a35249cce792db824c1bce3 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sat, 12 Jun 2021 15:21:08 +0000 Subject: [PATCH] Use Rc instead of Arc for login, as Arc doesn't seem to be required. --- web-ui/crate/src/components/login.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/web-ui/crate/src/components/login.rs b/web-ui/crate/src/components/login.rs index 4fe695e..41f930c 100644 --- a/web-ui/crate/src/components/login.rs +++ b/web-ui/crate/src/components/login.rs @@ -1,9 +1,8 @@ +use crate::api; use crate::error::UiError; -use crate::state::{Action, Room, WebUiDispatcher}; -use crate::{api, state::WebUiState}; -use std::sync::Arc; +use crate::state::{Action, WebUiDispatcher}; +use std::rc::Rc; use wasm_bindgen_futures::spawn_local; -use web_sys::console; use web_sys::FocusEvent; use yew::prelude::*; use yewdux::dispatch::Dispatcher; @@ -12,7 +11,7 @@ use yewtil::NeqAssign; #[doc(hidden)] pub(crate) struct YewduxLogin { - dispatch: Arc, + dispatch: Rc, link: ComponentLink, username: String, password: String, @@ -49,7 +48,7 @@ impl Component for YewduxLogin { fn create(dispatch: Self::Properties, link: ComponentLink) -> Self { Self { - dispatch: Arc::new(dispatch), + dispatch: Rc::new(dispatch), link, username: "".to_string(), password: "".to_string(), @@ -76,7 +75,7 @@ impl Component for YewduxLogin { } fn change(&mut self, dispatch: Self::Properties) -> ShouldRender { - self.dispatch.neq_assign(Arc::new(dispatch)) + self.dispatch.neq_assign(Rc::new(dispatch)) } fn rendered(&mut self, first_render: bool) { @@ -86,9 +85,6 @@ impl Component for YewduxLogin { } fn view(&self) -> Html { - let dispatch = Arc::new(self.dispatch.clone()); - let dispatch2 = dispatch.clone(); - // let do_the_login = self.dispatch.reduce_callback(|state| { // spawn_local(async move { // do_login(state, "user", "pw").await;