daydream

A small matrix web client written in rust
git clone git://archive.git.mtrnord.blog/daydream-mx/daydream.git
Log | Files | Refs | README | LICENSE

commit ea466700115e25f0c0654957569bf9edab18afab
parent ad542d87df8dc1cb0d4058872c2e51b778b5a3ab
Author: Marcel <mtrnord1@gmail.com>
Date:   Fri,  3 Jul 2020 20:27:40 +0200

Run cargo fmt

Took 4 minutes

Diffstat:
Msrc/app/components/room_list/item.rs | 2+-
Msrc/app/matrix/mod.rs | 16++++++++++------
Msrc/app/mod.rs | 7+------
Msrc/utils/notifications.rs | 2+-
4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/src/app/components/room_list/item.rs b/src/app/components/room_list/item.rs @@ -1,4 +1,4 @@ -use matrix_sdk::{events::room::message::MessageEventContent, Room, identifiers::RoomId}; +use matrix_sdk::{events::room::message::MessageEventContent, identifiers::RoomId, Room}; use yew::prelude::*; use yewtil::NeqAssign; diff --git a/src/app/matrix/mod.rs b/src/app/matrix/mod.rs @@ -1,6 +1,6 @@ -use std::collections::{HashSet}; +use std::collections::HashSet; use std::convert::TryFrom; -use std::sync::{Arc}; +use std::sync::Arc; use log::*; use matrix_sdk::{ @@ -221,7 +221,14 @@ impl Agent for MatrixAgent { }); } Request::GetLoggedIn => { - self.login(); + let login_client = self.login(); + if login_client.is_none() { + for sub in self.subscribers.iter() { + let resp = Response::Error(MatrixError::MissingClient); + self.link.respond(*sub, resp); + } + return; + } // Always clone agent after having tried to login! let agent = self.clone(); @@ -432,9 +439,6 @@ impl MatrixAgent { fn login(&mut self) -> Option<Client> { info!("preparing client"); - if self.session.is_none() { - return None; - } if self.session.is_some() { info!("restoring login"); let homeserver = self.session.clone().unwrap().homeserver_url; diff --git a/src/app/mod.rs b/src/app/mod.rs @@ -57,6 +57,7 @@ impl Component for App { }; let route_agent = RouteAgent::bridge(link.callback(Msg::RouteChanged)); let mut matrix_agent = MatrixAgent::bridge(link.callback(Msg::NewMessage)); + matrix_agent.send(matrix::Request::SetSession(session.clone().unwrap())); matrix_agent.send(matrix::Request::GetLoggedIn); App { matrix_agent, @@ -87,12 +88,6 @@ impl Component for App { } Response::Error(_) => {} Response::LoggedIn(logged_in) => { - if !logged_in && self.session.is_some() { - self.matrix_agent - .send(matrix::Request::SetSession(self.session.clone().unwrap())); - self.matrix_agent.send(matrix::Request::GetLoggedIn); - return false; - } let route: Route = if logged_in { //self.state.logged_in = true; diff --git a/src/utils/notifications.rs b/src/utils/notifications.rs @@ -1,5 +1,5 @@ -use wasm_bindgen::JsCast; use wasm_bindgen::prelude::*; +use wasm_bindgen::JsCast; use web_sys::{Notification, NotificationOptions, NotificationPermission}; #[derive(Clone)]