fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use gpui::*;
|
use gpui::*;
|
||||||
use ui::{Root, v_flex};
|
use ui::Root;
|
||||||
use universal_time::{
|
use universal_time::{
|
||||||
Duration, Instant, MonotonicClock, SystemTime, WallClock, define_time_provider,
|
Duration, Instant, MonotonicClock, SystemTime, WallClock, define_time_provider,
|
||||||
};
|
};
|
||||||
@@ -33,12 +33,15 @@ pub fn run() -> Result<(), JsValue> {
|
|||||||
|
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
gpui_platform::web_init();
|
gpui_platform::web_init();
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
let app = gpui_platform::application();
|
let app = gpui_platform::application();
|
||||||
|
|
||||||
#[cfg(target_family = "wasm")]
|
#[cfg(target_family = "wasm")]
|
||||||
let app = {
|
let app = {
|
||||||
let app = gpui_platform::single_threaded_web();
|
let app = gpui_platform::single_threaded_web();
|
||||||
// Temporary fix: intentionally leak the `Rc<AppCell>` to keep the application alive
|
|
||||||
|
// Workaround: intentionally leak the `Rc<AppCell>` to keep the application alive
|
||||||
struct WasmApplication(std::rc::Rc<AppCell>);
|
struct WasmApplication(std::rc::Rc<AppCell>);
|
||||||
let wasm_app = unsafe { std::mem::transmute::<Application, WasmApplication>(app) };
|
let wasm_app = unsafe { std::mem::transmute::<Application, WasmApplication>(app) };
|
||||||
std::mem::forget(wasm_app.0.clone());
|
std::mem::forget(wasm_app.0.clone());
|
||||||
@@ -46,16 +49,33 @@ pub fn run() -> Result<(), JsValue> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.run(|cx| {
|
app.run(|cx| {
|
||||||
// Initialize components
|
|
||||||
ui::init(cx);
|
|
||||||
|
|
||||||
// Initialize theme registry
|
|
||||||
theme::init(cx);
|
|
||||||
|
|
||||||
// Open the root window
|
// Open the root window
|
||||||
cx.open_window(WindowOptions::default(), |window, cx| {
|
cx.open_window(WindowOptions::default(), |window, cx| {
|
||||||
let view = cx.new(HelloWeb::new);
|
// Initialize components
|
||||||
cx.new(|cx| Root::new(view.into(), window, cx))
|
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.");
|
.expect("Failed to open window. Please restart the application.");
|
||||||
|
|
||||||
@@ -64,21 +84,3 @@ pub fn run() -> Result<(), JsValue> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HelloWeb {}
|
|
||||||
|
|
||||||
impl HelloWeb {
|
|
||||||
fn new(_cx: &mut Context<Self>) -> Self {
|
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Render for HelloWeb {
|
|
||||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
|
||||||
v_flex()
|
|
||||||
.size_full()
|
|
||||||
.items_center()
|
|
||||||
.justify_center()
|
|
||||||
.child("Hello web")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user