♻️ Add Session domain entity
This commit is contained in:
28
src/base.rs
28
src/base.rs
@@ -17,6 +17,7 @@ use matrix_sdk::{
|
|||||||
use tokio::select;
|
use tokio::select;
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
|
|
||||||
|
use crate::domain::model::session::Session;
|
||||||
use crate::ui::components::chats_window::interface::Interface as ChatsWinInterface;
|
use crate::ui::components::chats_window::interface::Interface as ChatsWinInterface;
|
||||||
|
|
||||||
// #[derive(Clone, Debug)]
|
// #[derive(Clone, Debug)]
|
||||||
@@ -243,33 +244,6 @@ pub async fn login(
|
|||||||
error!("=== LOGIN END ===");
|
error!("=== LOGIN END ===");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Session {
|
|
||||||
pub homeserver_url: Option<String>,
|
|
||||||
pub username: Option<String>,
|
|
||||||
pub password: Option<String>,
|
|
||||||
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<String>,
|
|
||||||
username: Option<String>,
|
|
||||||
password: Option<String>,
|
|
||||||
) {
|
|
||||||
self.homeserver_url = homeserver_url;
|
|
||||||
self.username = username;
|
|
||||||
self.password = password;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub static APP_SETTINGS: GlobalSignal<AppSettings> = Signal::global(AppSettings::new);
|
pub static APP_SETTINGS: GlobalSignal<AppSettings> = Signal::global(AppSettings::new);
|
||||||
pub static ROOMS: GlobalSignal<ByIdRooms> = Signal::global(ByIdRooms::new);
|
pub static ROOMS: GlobalSignal<ByIdRooms> = Signal::global(ByIdRooms::new);
|
||||||
pub static SESSION: GlobalSignal<Session> = Signal::global(Session::new);
|
pub static SESSION: GlobalSignal<Session> = Signal::global(Session::new);
|
||||||
|
1
src/domain/mod.rs
Normal file
1
src/domain/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub(crate) mod model;
|
1
src/domain/model/mod.rs
Normal file
1
src/domain/model/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub(crate) mod session;
|
26
src/domain/model/session.rs
Normal file
26
src/domain/model/session.rs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
pub struct Session {
|
||||||
|
pub homeserver_url: Option<String>,
|
||||||
|
pub username: Option<String>,
|
||||||
|
pub password: Option<String>,
|
||||||
|
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<String>,
|
||||||
|
username: Option<String>,
|
||||||
|
password: Option<String>,
|
||||||
|
) {
|
||||||
|
self.homeserver_url = homeserver_url;
|
||||||
|
self.username = username;
|
||||||
|
self.password = password;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
|
mod domain;
|
||||||
mod infrastructure;
|
mod infrastructure;
|
||||||
mod ui;
|
mod ui;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
@@ -9,7 +9,8 @@ use log::{debug, error, warn};
|
|||||||
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
use validator::{Validate, ValidateArgs, ValidateEmail, ValidationError, ValidationErrors};
|
||||||
use zxcvbn::zxcvbn;
|
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::{
|
use crate::infrastructure::services::random_svg_generators::{
|
||||||
generate_random_svg_shape, ShapeConfig,
|
generate_random_svg_shape, ShapeConfig,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user