chore: follow up on nip-4e (#195)

* update deps

* .

* remove resend button

* clean up

* .

* .

* .

* .

* .
This commit is contained in:
reya
2025-10-28 14:37:30 +07:00
committed by GitHub
parent b5ed079a0e
commit b9297d3a01
21 changed files with 199 additions and 176 deletions

View File

@@ -21,9 +21,10 @@ use nostr_sdk::prelude::*;
use registry::{Registry, RegistryEvent};
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use states::constants::{BOOTSTRAP_RELAYS, DEFAULT_SIDEBAR_WIDTH};
use states::state::{Announcement, AuthRequest, Response, SignalKind, UnwrappingStatus};
use states::{app_state, default_nip17_relays, default_nip65_relays};
use states::{
app_state, default_nip17_relays, default_nip65_relays, Announcement, AuthRequest, Response,
SignalKind, UnwrappingStatus, BOOTSTRAP_RELAYS, DEFAULT_SIDEBAR_WIDTH,
};
use theme::{ActiveTheme, Theme, ThemeMode};
use title_bar::TitleBar;
use ui::actions::{CopyPublicKey, OpenPublicKey};
@@ -324,7 +325,7 @@ impl ChatSpace {
}
fn load_encryption(&self, ann: Announcement, window: &Window, cx: &Context<Self>) {
log::info!("Loading encryption keys: {ann:?}");
log::info!("Found encryption announcement: {ann:?}");
cx.spawn_in(window, async move |this, cx| {
let state = app_state();

View File

@@ -6,8 +6,7 @@ use gpui::{
TitlebarOptions, WindowBackgroundAppearance, WindowBounds, WindowDecorations, WindowKind,
WindowOptions,
};
use states::app_state;
use states::constants::{APP_ID, CLIENT_NAME};
use states::{app_state, APP_ID, CLIENT_NAME};
use ui::Root;
use crate::actions::{load_embedded_fonts, quit, Quit};

View File

@@ -14,8 +14,7 @@ use key_store::KeyStore;
use nostr_connect::prelude::*;
use registry::Registry;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::BUNKER_TIMEOUT;
use states::{app_state, BUNKER_TIMEOUT};
use theme::ActiveTheme;
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants};

View File

@@ -17,13 +17,13 @@ use indexset::{BTreeMap, BTreeSet};
use itertools::Itertools;
use nostr_sdk::prelude::*;
use registry::message::{Message, RenderedMessage};
use registry::room::{Room, RoomKind, RoomSignal, SendOptions, SendReport, SignerKind};
use registry::room::{Room, RoomKind, RoomSignal, SendOptions, SendReport};
use registry::Registry;
use serde::Deserialize;
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use smol::fs;
use states::app_state;
use states::{app_state, SignerKind};
use theme::ActiveTheme;
use ui::actions::{CopyPublicKey, OpenPublicKey};
use ui::avatar::Avatar;
@@ -107,6 +107,15 @@ impl Chat {
let mut subscriptions = smallvec![];
let mut tasks = smallvec![];
tasks.push(
// Get messaging relays and encryption keys announcement for all members
cx.background_spawn(async move {
if let Err(e) = connect.await {
log::error!("Failed to initialize room: {e}");
}
}),
);
tasks.push(
// Load all messages belonging to this room
cx.spawn_in(window, async move |this, cx| {
@@ -126,15 +135,6 @@ impl Chat {
}),
);
tasks.push(
// Get messaging relays and encryption keys announcement for all members
cx.background_spawn(async move {
if let Err(e) = connect.await {
log::error!("Failed to initialize room: {e}");
}
}),
);
subscriptions.push(
// Subscribe to input events
cx.subscribe_in(
@@ -346,6 +346,7 @@ impl Chat {
}
/// Resend a failed message
#[allow(dead_code)]
fn resend_message(&mut self, id: &EventId, window: &mut Window, cx: &mut Context<Self>) {
if let Some(reports) = self.reports_by_id.get(id).cloned() {
let id_clone = id.to_owned();
@@ -705,23 +706,7 @@ impl Chat {
})
.child(text)
.when(is_sent_failed, |this| {
this.child(
h_flex()
.gap_1()
.child(self.render_message_reports(&id, cx))
.child(
Button::new(SharedString::from(id.to_hex()))
.label(t!("common.resend"))
.danger()
.xsmall()
.rounded()
.on_click(cx.listener(
move |this, _, window, cx| {
this.resend_message(&id, window, cx);
},
)),
),
)
this.child(self.render_message_reports(&id, cx))
}),
),
)

View File

@@ -17,8 +17,7 @@ use registry::room::Room;
use registry::Registry;
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::BOOTSTRAP_RELAYS;
use states::{app_state, BOOTSTRAP_RELAYS};
use theme::ActiveTheme;
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants};

View File

@@ -11,8 +11,7 @@ use key_store::backend::KeyItem;
use key_store::KeyStore;
use nostr_connect::prelude::*;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::BUNKER_TIMEOUT;
use states::{app_state, BUNKER_TIMEOUT};
use theme::ActiveTheme;
use ui::button::{Button, ButtonVariants};
use ui::dock_area::panel::{Panel, PanelEvent};

View File

@@ -12,8 +12,7 @@ use key_store::KeyStore;
use nostr_sdk::prelude::*;
use settings::AppSettings;
use smol::fs;
use states::constants::BOOTSTRAP_RELAYS;
use states::{app_state, default_nip17_relays, default_nip65_relays};
use states::{app_state, default_nip17_relays, default_nip65_relays, BOOTSTRAP_RELAYS};
use theme::ActiveTheme;
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants};

View File

@@ -13,8 +13,7 @@ use key_store::backend::KeyItem;
use key_store::KeyStore;
use nostr_connect::prelude::*;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::{CLIENT_NAME, NOSTR_CONNECT_RELAY, NOSTR_CONNECT_TIMEOUT};
use states::{app_state, CLIENT_NAME, NOSTR_CONNECT_RELAY, NOSTR_CONNECT_TIMEOUT};
use theme::ActiveTheme;
use ui::button::{Button, ButtonVariants};
use ui::dock_area::panel::{Panel, PanelEvent};

View File

@@ -13,8 +13,7 @@ use nostr_sdk::prelude::*;
use registry::Registry;
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::BOOTSTRAP_RELAYS;
use states::{app_state, BOOTSTRAP_RELAYS};
use theme::ActiveTheme;
use ui::avatar::Avatar;
use ui::button::{Button, ButtonVariants};

View File

@@ -20,8 +20,7 @@ use registry::room::{Room, RoomKind};
use registry::{Registry, RegistryEvent};
use settings::AppSettings;
use smallvec::{smallvec, SmallVec};
use states::app_state;
use states::constants::{BOOTSTRAP_RELAYS, SEARCH_RELAYS};
use states::{app_state, BOOTSTRAP_RELAYS, SEARCH_RELAYS};
use theme::ActiveTheme;
use ui::button::{Button, ButtonVariants};
use ui::dock_area::panel::{Panel, PanelEvent};
@@ -626,7 +625,7 @@ impl Sidebar {
.name(this.display_name(cx))
.avatar(this.display_image(proxy, cx))
.created_at(this.created_at.to_ago())
.public_key(this.members.iter().nth(0).unwrap().0)
.public_key(&this.members[0])
.kind(this.kind)
.on_click(handler),
)