This commit is contained in:
2026-07-27 16:29:25 +07:00
parent da7167013f
commit e85974497b
4 changed files with 12 additions and 11 deletions

View File

@@ -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

View File

@@ -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<bool>,
/// Sent message ids
sent_ids: Arc<AsyncRwLock<Vec<EventId>>>,
sent_ids: Arc<Mutex<Vec<EventId>>>,
/// Replies to
replies_to: Entity<HashSet<EventId>>,
@@ -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| {

View File

@@ -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(())