From a7bccfa77997e6945f1bc236d8f37c2a0f55523b Mon Sep 17 00:00:00 2001 From: Adrien Date: Wed, 10 Apr 2024 12:48:01 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Add=20Session=20domain?= =?UTF-8?q?=20entity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/base.rs | 28 +--------------------------- src/domain/mod.rs | 1 + src/domain/model/mod.rs | 1 + src/domain/model/session.rs | 26 ++++++++++++++++++++++++++ src/main.rs | 1 + src/ui/components/login.rs | 3 ++- 6 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 src/domain/mod.rs create mode 100644 src/domain/model/mod.rs create mode 100644 src/domain/model/session.rs diff --git a/src/base.rs b/src/base.rs index a73a78f..6f73c6f 100644 --- a/src/base.rs +++ b/src/base.rs @@ -17,6 +17,7 @@ use matrix_sdk::{ use tokio::select; use log::{debug, error, warn}; +use crate::domain::model::session::Session; use crate::ui::components::chats_window::interface::Interface as ChatsWinInterface; // #[derive(Clone, Debug)] @@ -243,33 +244,6 @@ pub async fn login( error!("=== LOGIN END ==="); } -pub struct Session { - pub homeserver_url: Option, - pub username: Option, - pub password: Option, - pub is_logged: bool, -} -impl Session { - pub fn new() -> Self { - Self { - homeserver_url: None, - username: None, - password: None, - is_logged: false, - } - } - pub fn update( - &mut self, - homeserver_url: Option, - username: Option, - password: Option, - ) { - self.homeserver_url = homeserver_url; - self.username = username; - self.password = password; - } -} - pub static APP_SETTINGS: GlobalSignal = Signal::global(AppSettings::new); pub static ROOMS: GlobalSignal = Signal::global(ByIdRooms::new); pub static SESSION: GlobalSignal = Signal::global(Session::new); diff --git a/src/domain/mod.rs b/src/domain/mod.rs new file mode 100644 index 0000000..d9a5251 --- /dev/null +++ b/src/domain/mod.rs @@ -0,0 +1 @@ +pub(crate) mod model; diff --git a/src/domain/model/mod.rs b/src/domain/model/mod.rs new file mode 100644 index 0000000..bd1b488 --- /dev/null +++ b/src/domain/model/mod.rs @@ -0,0 +1 @@ +pub(crate) mod session; diff --git a/src/domain/model/session.rs b/src/domain/model/session.rs new file mode 100644 index 0000000..e1191bc --- /dev/null +++ b/src/domain/model/session.rs @@ -0,0 +1,26 @@ +pub struct Session { + pub homeserver_url: Option, + pub username: Option, + pub password: Option, + pub is_logged: bool, +} +impl Session { + pub fn new() -> Self { + Self { + homeserver_url: None, + username: None, + password: None, + is_logged: false, + } + } + pub fn update( + &mut self, + homeserver_url: Option, + username: Option, + password: Option, + ) { + self.homeserver_url = homeserver_url; + self.username = username; + self.password = password; + } +} diff --git a/src/main.rs b/src/main.rs index e536ce3..e96cfb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![allow(non_snake_case)] +mod domain; mod infrastructure; mod ui; mod utils; diff --git a/src/ui/components/login.rs b/src/ui/components/login.rs index 9f84937..f10b6d1 100644 --- a/src/ui/components/login.rs +++ b/src/ui/components/login.rs @@ -9,7 +9,8 @@ use log::{debug, error, warn}; use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors}; use zxcvbn::zxcvbn; -use crate::base::{Session, SESSION}; +use crate::base::SESSION; +use crate::domain::model::session::Session; use crate::infrastructure::services::random_svg_generators::{ generate_random_svg_shape, ShapeConfig, };