diff --git a/web/src/lib.rs b/web/src/lib.rs index 8c95556..71850e3 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -1,5 +1,5 @@ use gpui::*; -use ui::{Root, v_flex}; +use ui::Root; use universal_time::{ Duration, Instant, MonotonicClock, SystemTime, WallClock, define_time_provider, }; @@ -33,12 +33,15 @@ pub fn run() -> Result<(), JsValue> { #[cfg(target_family = "wasm")] gpui_platform::web_init(); + #[cfg(not(target_family = "wasm"))] let app = gpui_platform::application(); + #[cfg(target_family = "wasm")] let app = { let app = gpui_platform::single_threaded_web(); - // Temporary fix: intentionally leak the `Rc` to keep the application alive + + // Workaround: intentionally leak the `Rc` to keep the application alive struct WasmApplication(std::rc::Rc); let wasm_app = unsafe { std::mem::transmute::(app) }; std::mem::forget(wasm_app.0.clone()); @@ -46,16 +49,33 @@ pub fn run() -> Result<(), JsValue> { }; app.run(|cx| { - // Initialize components - ui::init(cx); - - // Initialize theme registry - theme::init(cx); - // Open the root window cx.open_window(WindowOptions::default(), |window, cx| { - let view = cx.new(HelloWeb::new); - cx.new(|cx| Root::new(view.into(), window, cx)) + // Initialize components + ui::init(cx); + + // Initialize theme registry + theme::init(cx); + + // Initialize settings + settings::init(window, cx); + + // Initialize the nostr client + state::init(window, cx); + + // Initialize person registry + person::init(window, cx); + + // Initialize device signer + // + // NIP-4e: https://github.com/nostr-protocol/nips/blob/per-device-keys/4e.md + device::init(window, cx); + + // Initialize app registry + chat::init(window, cx); + + // Root view + cx.new(|cx| Root::new(workspace::init(window, cx).into(), window, cx)) }) .expect("Failed to open window. Please restart the application."); @@ -64,21 +84,3 @@ pub fn run() -> Result<(), JsValue> { Ok(()) } - -struct HelloWeb {} - -impl HelloWeb { - fn new(_cx: &mut Context) -> Self { - Self {} - } -} - -impl Render for HelloWeb { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - v_flex() - .size_full() - .items_center() - .justify_center() - .child("Hello web") - } -}