🏗️ Remove data handling from components

The data sent by matrix_interface senders is now handled by the App.
This commit is contained in:
2023-12-21 22:07:08 +01:00
parent 513b05ddb3
commit c9292fd613
7 changed files with 177 additions and 71 deletions

View File

@@ -8,19 +8,36 @@ use tracing::{debug, Level};
pub mod components;
pub mod matrix_interface;
use crate::base::APP_SETTINGS;
use crate::base::{login, sync_rooms, APP_SETTINGS, ROOMS, SESSION};
use crate::components::chats_window::chats_window::ChatsWindow;
use crate::components::main_window::MainWindow;
mod base;
fn App(cx: Scope) -> Element {
debug!("App rendering");
debug!("*** App rendering ***");
use_init_atom_root(cx);
let app_settings = use_atom_ref(cx, &APP_SETTINGS);
let is_logged = app_settings.read().store.is_logged;
let app_settings_ref = use_atom_ref(cx, &APP_SETTINGS);
let session_ref = use_atom_ref(cx, &SESSION);
let rooms_ref = use_atom_ref(cx, &ROOMS);
let login_coro = use_coroutine(cx, |rx| {
login(rx, app_settings_ref.clone(), session_ref.clone())
});
let sync_rooms_coro = use_coroutine(cx, |rx| {
sync_rooms(rx, app_settings_ref.clone(), rooms_ref.clone())
});
let is_logged = session_ref.read().is_logged;
login_coro.send(is_logged);
if is_logged {
sync_rooms_coro.send(is_logged);
}
let chats_win_state = use_state(cx, || None);