diff --git a/Cargo.lock b/Cargo.lock index a046802..3ad9529 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1076,6 +1076,7 @@ dependencies = [ "chat", "common", "flume 0.11.1", + "futures", "gpui", "itertools 0.13.0", "linkify", @@ -1086,7 +1087,6 @@ dependencies = [ "serde", "settings", "smallvec", - "smol", "state", "theme", "ui", diff --git a/crates/chat_ui/Cargo.toml b/crates/chat_ui/Cargo.toml index 0cc8ed3..fd2c1f1 100644 --- a/crates/chat_ui/Cargo.toml +++ b/crates/chat_ui/Cargo.toml @@ -19,11 +19,10 @@ anyhow.workspace = true itertools.workspace = true smallvec.workspace = true flume.workspace = true +futures.workspace = true log.workspace = true serde.workspace = true linkify = "0.10.0" pulldown-cmark = "0.13.1" -[target.'cfg(not(target_arch = "wasm32"))'.dependencies] -smol.workspace = true diff --git a/crates/chat_ui/src/lib.rs b/crates/chat_ui/src/lib.rs index a00434f..9d3a002 100644 --- a/crates/chat_ui/src/lib.rs +++ b/crates/chat_ui/src/lib.rs @@ -1,12 +1,11 @@ use std::collections::{BTreeMap, BTreeSet, HashSet}; -#[cfg(target_arch = "wasm32")] -use std::sync::RwLock as AsyncRwLock; use std::sync::{Arc, RwLock}; pub use actions::*; use anyhow::{Context as AnyhowContext, Error}; use chat::{ChatRegistry, Message, Room, RoomEvent, SendReport, SendStatus}; use common::{TimestampExt, coop_cache}; +use futures::lock::Mutex; use gpui::prelude::FluentBuilder; use gpui::{ AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, @@ -20,8 +19,6 @@ use nostr_sdk::prelude::*; use person::{Person, PersonRegistry}; use settings::{AppSettings, SignerKind}; use smallvec::{SmallVec, smallvec}; -#[cfg(not(target_arch = "wasm32"))] -use smol::lock::RwLock as AsyncRwLock; use state::{NostrRegistry, upload}; use theme::ActiveTheme; use ui::avatar::Avatar; @@ -75,7 +72,7 @@ pub struct ChatPanel { subject_bar: Entity, /// Sent message ids - sent_ids: Arc>>, + sent_ids: Arc>>, /// Replies to replies_to: Entity>, @@ -172,7 +169,7 @@ impl ChatPanel { attachments, rendered_texts_by_id: BTreeMap::new(), reports_by_id, - sent_ids: Arc::new(AsyncRwLock::new(Vec::new())), + sent_ids: Arc::new(Mutex::new(Vec::new())), uploading: false, subscriptions, tasks: vec![], @@ -207,7 +204,7 @@ impl ChatPanel { message, } = *message { - let sent_ids = sent_ids.read().await; + let sent_ids = sent_ids.lock().await; if sent_ids.contains(&event_id) { let status = if status { @@ -378,7 +375,7 @@ impl ChatPanel { self.tasks.push(cx.spawn_in(window, async move |this, cx| { let outputs = send_task.await; - let mut sent_ids = sent_ids.write().await; + let mut sent_ids = sent_ids.lock().await; sent_ids.extend(outputs.iter().filter_map(|output| output.gift_wrap_id)); this.update(cx, |this, cx| { diff --git a/crates/device/src/lib.rs b/crates/device/src/lib.rs index d3b5da3..98efdf7 100644 --- a/crates/device/src/lib.rs +++ b/crates/device/src/lib.rs @@ -225,6 +225,11 @@ impl DeviceRegistry { let keys = get_keys(&client, &signer).await?; let content = keys.secret_key().to_bech32()?; + if cfg!(target_arch = "wasm32") { + return Err(anyhow!("Not supported")); + } + + #[cfg(not(target_arch = "wasm32"))] smol::fs::write(path, &content).await?; Ok(())