@@ -10,7 +10,7 @@ use gpui::{
|
||||
};
|
||||
use nostr_sdk::prelude::*;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use state::{NostrRegistry, TIMEOUT};
|
||||
use state::NostrRegistry;
|
||||
use theme::ActiveTheme;
|
||||
use ui::button::{Button, ButtonVariants};
|
||||
use ui::dock_area::panel::{Panel, PanelEvent};
|
||||
@@ -170,6 +170,15 @@ impl MessagingRelayPanel {
|
||||
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
let client = nostr.read(cx).client();
|
||||
let signer = nostr.read(cx).signer();
|
||||
|
||||
let Some(public_key) = signer.public_key() else {
|
||||
window.push_notification("Public Key not found", cx);
|
||||
return;
|
||||
};
|
||||
|
||||
// Get user's write relays
|
||||
let write_relays = nostr.read(cx).write_relays(&public_key, cx);
|
||||
|
||||
// Construct event tags
|
||||
let tags: Vec<Tag> = self
|
||||
@@ -182,16 +191,14 @@ impl MessagingRelayPanel {
|
||||
self.set_updating(true, cx);
|
||||
|
||||
let task: Task<Result<(), Error>> = cx.background_spawn(async move {
|
||||
let urls = write_relays.await;
|
||||
|
||||
// Construct nip17 event builder
|
||||
let builder = EventBuilder::new(Kind::InboxRelays, "").tags(tags);
|
||||
let event = client.sign_event_builder(builder).await?;
|
||||
|
||||
// Set messaging relays
|
||||
client
|
||||
.send_event(&event)
|
||||
.to_nip65()
|
||||
.ok_timeout(Duration::from_secs(TIMEOUT))
|
||||
.await?;
|
||||
client.send_event(&event).to(urls).await?;
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
||||
@@ -582,6 +582,47 @@ impl Workspace {
|
||||
.dropdown_menu(move |this, _window, _cx| {
|
||||
this.min_w(px(260.))
|
||||
.label("Relays")
|
||||
.menu_element_with_disabled(
|
||||
Box::new(Command::ShowRelayList),
|
||||
true,
|
||||
move |_window, cx| {
|
||||
let nostr = NostrRegistry::global(cx);
|
||||
let urls = nostr.read(cx).read_only_relays(&pkey, cx);
|
||||
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.w_full()
|
||||
.items_start()
|
||||
.justify_start()
|
||||
.children({
|
||||
let mut items = vec![];
|
||||
|
||||
for url in urls.into_iter() {
|
||||
items.push(
|
||||
h_flex()
|
||||
.h_6()
|
||||
.w_full()
|
||||
.gap_2()
|
||||
.px_2()
|
||||
.text_xs()
|
||||
.bg(cx
|
||||
.theme()
|
||||
.elevated_surface_background)
|
||||
.rounded(cx.theme().radius)
|
||||
.child(
|
||||
div()
|
||||
.size_1()
|
||||
.rounded_full()
|
||||
.bg(gpui::green()),
|
||||
)
|
||||
.child(url),
|
||||
);
|
||||
}
|
||||
|
||||
items
|
||||
})
|
||||
},
|
||||
)
|
||||
.separator()
|
||||
.menu_with_icon(
|
||||
"Reload",
|
||||
|
||||
Reference in New Issue
Block a user