diff --git a/crates/state/src/lib.rs b/crates/state/src/lib.rs index 929aa0d..28c3f04 100644 --- a/crates/state/src/lib.rs +++ b/crates/state/src/lib.rs @@ -130,6 +130,7 @@ impl NostrRegistry { // Connect to bootstrap relays after the window is ready cx.defer_in(window, |this, _window, cx| { this.connect_bootstrap_relays(cx); + #[cfg(not(target_arch = "wasm32"))] this.get_user_credential(cx); }); diff --git a/crates/ui/src/dock/dock.rs b/crates/ui/src/dock/dock.rs index df302bd..4fb4321 100644 --- a/crates/ui/src/dock/dock.rs +++ b/crates/ui/src/dock/dock.rs @@ -214,6 +214,8 @@ impl Dock { pub fn set_open(&mut self, open: bool, window: &mut Window, cx: &mut Context) { self.open = open; let item = self.panel.clone(); + // Use defer_in (not window.defer) so the callback is cancelled + // if this Dock entity is dropped before the deferred frame runs. cx.defer_in(window, move |_, window, cx| { item.set_collapsed(!open, window, cx); }); diff --git a/crates/workspace/src/dialogs/screening.rs b/crates/workspace/src/dialogs/screening.rs index 45a61a0..a5e7c06 100644 --- a/crates/workspace/src/dialogs/screening.rs +++ b/crates/workspace/src/dialogs/screening.rs @@ -55,7 +55,7 @@ impl Screening { window.close_all_modals(cx); })); - cx.defer_in(window, move |this, _window, cx| { + cx.defer_in(window, |this, _window, cx| { this.check_contact(cx); this.check_wot(cx); this.check_last_activity(cx); diff --git a/desktop/src/main.rs b/desktop/src/main.rs index dd4083e..05c6af5 100644 --- a/desktop/src/main.rs +++ b/desktop/src/main.rs @@ -62,36 +62,34 @@ fn main() { // Open a window with default options cx.open_window(opts, |window, cx| { - cx.new(|cx| { - // Initialize components - ui::init(cx); + // Initialize components + ui::init(cx); - // Initialize theme registry - theme::init(cx); + // Initialize theme registry + theme::init(cx); - // Initialize settings - settings::init(window, cx); + // Initialize settings + settings::init(window, cx); - // Initialize the nostr client - state::init(window, cx); + // Initialize the nostr client + state::init(window, cx); - // Initialize person registry - person::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 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); + // Initialize app registry + chat::init(window, cx); - // Initialize auto update - auto_update::init(window, cx); + // Initialize auto update + auto_update::init(window, cx); - // Root Entity - Root::new(workspace::init(window, cx).into(), 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."); diff --git a/web/script/build-wasm.sh b/web/script/build-wasm.sh index 931a85a..220b8bf 100755 --- a/web/script/build-wasm.sh +++ b/web/script/build-wasm.sh @@ -39,8 +39,8 @@ fi echo -e "${GREEN}Step 1: Building WASM...${NC}" cd "$PROJECT_ROOT" export CARGO_TARGET_DIR="$PROJECT_ROOT/target" -RUSTFLAGS='-C target-feature=+atomics,+bulk-memory -C link-arg=--shared-memory -C link-arg=--max-memory=4294967296 -C link-arg=--import-memory -C link-arg=--export=__heap_base -C link-arg=--export=__wasm_init_tls -C link-arg=--export=__tls_size -C link-arg=--export=__tls_align -C link-arg=--export=__tls_base' \ - cargo build --target wasm32-unknown-unknown $RELEASE_FLAG +RUSTFLAGS='-C target-feature=+bulk-memory -C link-arg=--max-memory=4294967296' \ +cargo build --target wasm32-unknown-unknown $RELEASE_FLAG # Determine the build directory if [[ "$RELEASE_FLAG" == "--release" ]]; then @@ -58,10 +58,6 @@ if [[ ! -f "$WASM_PATH" ]]; then exit 1 fi -# Step 1.5: Force shared memory (linker --shared-memory is not working) -echo -e "${GREEN}Step 1.5: Enabling shared memory...${NC}" -wasm-opt --enable-threads "$WASM_PATH" -o "$WASM_PATH" - # Step 2: Generate JavaScript bindings echo -e "${GREEN}Step 2: Generating JavaScript bindings...${NC}" wasm-bindgen "$WASM_PATH" \