First try of making reactive state external using UseRw

This commit is contained in:
2023-08-09 22:54:32 +02:00
parent 2bbee1633f
commit 22ef914304
4 changed files with 60 additions and 36 deletions

View File

@@ -1,12 +1,12 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;
use dioxus_desktop::Config;
use dioxus_std::utils::rw::use_rw;
pub mod app_settings;
pub mod components;
pub mod matrix_client;
use crate::app_settings::AppSettings;
use crate::base::{AppSettings, Store};
use crate::components::contacts_window::ContactWindow;
use crate::components::login::Login;
@@ -15,18 +15,16 @@ mod base;
fn App(cx: Scope<AppSettings>) -> Element {
use_shared_state_provider(cx, || cx.props.clone());
let app_context = use_shared_state::<AppSettings>(cx).unwrap();
let store = use_rw(cx, || Store::new());
// let window = dioxus_desktop::use_window(cx);
// let dom = VirtualDom::new(ControlWindow);
// window.new_window(dom, cx.props.clone());
let is_logged = store.read().unwrap().is_logged;
cx.render(rsx! {
if app_context.read().store.is_logged {
if is_logged {
rsx!(ContactWindow {})
}
else {
rsx!(Login {})
rsx!(Login {store: store})
}
})
}