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

2
Cargo.lock generated
View File

@@ -1076,6 +1076,7 @@ dependencies = [
"chat", "chat",
"common", "common",
"flume 0.11.1", "flume 0.11.1",
"futures",
"gpui", "gpui",
"itertools 0.13.0", "itertools 0.13.0",
"linkify", "linkify",
@@ -1086,7 +1087,6 @@ dependencies = [
"serde", "serde",
"settings", "settings",
"smallvec", "smallvec",
"smol",
"state", "state",
"theme", "theme",
"ui", "ui",

View File

@@ -19,11 +19,10 @@ anyhow.workspace = true
itertools.workspace = true itertools.workspace = true
smallvec.workspace = true smallvec.workspace = true
flume.workspace = true flume.workspace = true
futures.workspace = true
log.workspace = true log.workspace = true
serde.workspace = true serde.workspace = true
linkify = "0.10.0" linkify = "0.10.0"
pulldown-cmark = "0.13.1" 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}; use std::collections::{BTreeMap, BTreeSet, HashSet};
#[cfg(target_arch = "wasm32")]
use std::sync::RwLock as AsyncRwLock;
use std::sync::{Arc, RwLock}; use std::sync::{Arc, RwLock};
pub use actions::*; pub use actions::*;
use anyhow::{Context as AnyhowContext, Error}; use anyhow::{Context as AnyhowContext, Error};
use chat::{ChatRegistry, Message, Room, RoomEvent, SendReport, SendStatus}; use chat::{ChatRegistry, Message, Room, RoomEvent, SendReport, SendStatus};
use common::{TimestampExt, coop_cache}; use common::{TimestampExt, coop_cache};
use futures::lock::Mutex;
use gpui::prelude::FluentBuilder; use gpui::prelude::FluentBuilder;
use gpui::{ use gpui::{
AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle, AnyElement, App, AppContext, ClipboardItem, Context, Entity, EventEmitter, FocusHandle,
@@ -20,8 +19,6 @@ use nostr_sdk::prelude::*;
use person::{Person, PersonRegistry}; use person::{Person, PersonRegistry};
use settings::{AppSettings, SignerKind}; use settings::{AppSettings, SignerKind};
use smallvec::{SmallVec, smallvec}; use smallvec::{SmallVec, smallvec};
#[cfg(not(target_arch = "wasm32"))]
use smol::lock::RwLock as AsyncRwLock;
use state::{NostrRegistry, upload}; use state::{NostrRegistry, upload};
use theme::ActiveTheme; use theme::ActiveTheme;
use ui::avatar::Avatar; use ui::avatar::Avatar;
@@ -75,7 +72,7 @@ pub struct ChatPanel {
subject_bar: Entity<bool>, subject_bar: Entity<bool>,
/// Sent message ids /// Sent message ids
sent_ids: Arc<AsyncRwLock<Vec<EventId>>>, sent_ids: Arc<Mutex<Vec<EventId>>>,
/// Replies to /// Replies to
replies_to: Entity<HashSet<EventId>>, replies_to: Entity<HashSet<EventId>>,
@@ -172,7 +169,7 @@ impl ChatPanel {
attachments, attachments,
rendered_texts_by_id: BTreeMap::new(), rendered_texts_by_id: BTreeMap::new(),
reports_by_id, reports_by_id,
sent_ids: Arc::new(AsyncRwLock::new(Vec::new())), sent_ids: Arc::new(Mutex::new(Vec::new())),
uploading: false, uploading: false,
subscriptions, subscriptions,
tasks: vec![], tasks: vec![],
@@ -207,7 +204,7 @@ impl ChatPanel {
message, message,
} = *message } = *message
{ {
let sent_ids = sent_ids.read().await; let sent_ids = sent_ids.lock().await;
if sent_ids.contains(&event_id) { if sent_ids.contains(&event_id) {
let status = if status { let status = if status {
@@ -378,7 +375,7 @@ impl ChatPanel {
self.tasks.push(cx.spawn_in(window, async move |this, cx| { self.tasks.push(cx.spawn_in(window, async move |this, cx| {
let outputs = send_task.await; 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)); sent_ids.extend(outputs.iter().filter_map(|output| output.gift_wrap_id));
this.update(cx, |this, cx| { this.update(cx, |this, cx| {

View File

@@ -225,6 +225,11 @@ impl DeviceRegistry {
let keys = get_keys(&client, &signer).await?; let keys = get_keys(&client, &signer).await?;
let content = keys.secret_key().to_bech32()?; 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?; smol::fs::write(path, &content).await?;
Ok(()) Ok(())