diff --git a/app/src/app.rs b/app/src/app.rs index 354ab71..dae4839 100644 --- a/app/src/app.rs +++ b/app/src/app.rs @@ -40,7 +40,7 @@ impl Component for App { fn create(_: Self::Properties, link: ComponentLink) -> Self { let mut app = Self { - link: link.clone(), + link, user_name: get_cookie("user_id").unwrap_or_else(|e| { ConsoleService::error(&e.to_string()); None @@ -89,7 +89,7 @@ impl Component for App { render = Router::render(move |switch: AppRoute| { match switch { AppRoute::Login => html! { - + }, AppRoute::Index | AppRoute::ListUsers => html! {
@@ -112,7 +112,7 @@ impl App { if current_route.is_empty() || current_route.contains("login") { String::from("/") } else { - current_route.into() + current_route } } } diff --git a/app/src/cookies.rs b/app/src/cookies.rs index f3462d5..d79984a 100644 --- a/app/src/cookies.rs +++ b/app/src/cookies.rs @@ -7,7 +7,7 @@ fn get_document() -> Result { web_sys::window() .map(|w| w.document()) .flatten() - .ok_or(anyhow!("Could not get window document")) + .ok_or_else(|| anyhow!("Could not get window document")) .and_then(|d| { d.dyn_into::() .map_err(|_| anyhow!("Document is not an HTMLDocument")) @@ -18,7 +18,7 @@ pub fn set_cookie(cookie_name: &str, value: &str, expiration: &DateTime) -> let doc = web_sys::window() .map(|w| w.document()) .flatten() - .ok_or(anyhow!("Could not get window document")) + .ok_or_else(|| anyhow!("Could not get window document")) .and_then(|d| { d.dyn_into::() .map_err(|_| anyhow!("Document is not an HTMLDocument")) @@ -35,7 +35,7 @@ pub fn get_cookie(cookie_name: &str) -> Result> { .cookie() .map_err(|_| anyhow!("Could not access cookies"))?; Ok(cookies - .split(";") + .split(';') .filter_map(|c| c.split_once('=')) .find_map(|(name, value)| { if name == cookie_name { @@ -51,7 +51,7 @@ pub fn get_cookie(cookie_name: &str) -> Result> { } pub fn delete_cookie(cookie_name: &str) -> Result<()> { - if let Some(_) = get_cookie(cookie_name)? { + if get_cookie(cookie_name)?.is_some() { set_cookie(cookie_name, "", &Utc.ymd(1970, 1, 1).and_hms(0, 0, 0)) } else { Ok(()) diff --git a/app/src/login.rs b/app/src/login.rs index c781fd6..6cb2655 100644 --- a/app/src/login.rs +++ b/app/src/login.rs @@ -38,7 +38,7 @@ impl Component for LoginForm { fn create(props: Self::Properties, link: ComponentLink) -> Self { LoginForm { - link: link.clone(), + link, on_logged_in: props.on_logged_in, error: None, node_ref: NodeRef::default(), @@ -63,8 +63,8 @@ impl Component for LoginForm { .unwrap() .value(); let req = BindRequest { - name: username.to_string(), - password: password.to_string(), + name: username, + password, }; match HostService::authenticate( req, diff --git a/app/src/logout.rs b/app/src/logout.rs index c7d84ff..a4b3e0c 100644 --- a/app/src/logout.rs +++ b/app/src/logout.rs @@ -26,7 +26,7 @@ impl Component for LogoutButton { fn create(props: Self::Properties, link: ComponentLink) -> Self { LogoutButton { - link: link.clone(), + link, on_logged_out: props.on_logged_out, _task: None, } diff --git a/app/src/user_table.rs b/app/src/user_table.rs index de9097d..dfba040 100644 --- a/app/src/user_table.rs +++ b/app/src/user_table.rs @@ -34,7 +34,7 @@ impl Component for UserTable { fn create(_: Self::Properties, link: ComponentLink) -> Self { let mut table = UserTable { - link: link.clone(), + link, _task: None, users: None, };