🏗️ Rearchitecting the interface with the MatrixClient
- Replace RwStore with channels. - Use of fermi to handle application data. - Use of tracing.
This commit is contained in:
52
src/main.rs
52
src/main.rs
@@ -2,45 +2,47 @@
|
||||
|
||||
use dioxus::prelude::*;
|
||||
use dioxus_desktop::Config;
|
||||
use dioxus_std::utils::rw::use_rw;
|
||||
use fermi::*;
|
||||
use tracing::{debug, Level};
|
||||
|
||||
pub mod components;
|
||||
pub mod matrix_client;
|
||||
|
||||
use crate::base::AppSettings;
|
||||
use crate::base::Store;
|
||||
use crate::base::APP_SETTINGS;
|
||||
use crate::components::chats_window::chats_window::ChatsWindow;
|
||||
use crate::components::main_window::MainWindow;
|
||||
|
||||
mod base;
|
||||
|
||||
fn App(cx: Scope<AppSettings>) -> Element {
|
||||
use_shared_state_provider(cx, || cx.props.clone());
|
||||
fn App(cx: Scope) -> Element {
|
||||
debug!("App rendering");
|
||||
|
||||
let rw_store = use_rw(cx, || Store::new());
|
||||
use_init_atom_root(cx);
|
||||
|
||||
let is_logged = rw_store.read().unwrap().is_logged;
|
||||
let app_settings = use_atom_ref(cx, &APP_SETTINGS);
|
||||
let is_logged = app_settings.read().store.is_logged;
|
||||
|
||||
let chats_win_state = use_state(cx, || None);
|
||||
|
||||
if is_logged && chats_win_state.is_none() {
|
||||
let chats_window = dioxus_desktop::use_window(cx);
|
||||
|
||||
let chats_dom = VirtualDom::new(ChatsWindow);
|
||||
let window_cfg = Config::default().with_custom_head(
|
||||
r#"
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
margin: 0;
|
||||
}
|
||||
#main, #bodywrap {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
"#
|
||||
margin: 0;
|
||||
}
|
||||
#main, #bodywrap {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
"#
|
||||
.to_owned(),
|
||||
);
|
||||
let chats_window_desktop_service = chats_window.new_window(chats_dom, window_cfg);
|
||||
@@ -48,17 +50,19 @@ fn App(cx: Scope<AppSettings>) -> Element {
|
||||
}
|
||||
|
||||
cx.render(rsx! {
|
||||
MainWindow {rw_store: rw_store}
|
||||
MainWindow {}
|
||||
})
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt()
|
||||
// .pretty()
|
||||
.with_max_level(Level::DEBUG)
|
||||
.init();
|
||||
|
||||
let app_settings = AppSettings::new();
|
||||
|
||||
dioxus_desktop::launch_with_props(App, app_settings, Config::default());
|
||||
dioxus_desktop::launch(App);
|
||||
// dioxus_web::launch(App);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user