From 26f5f1c06fb00f7de807b37ac3dc9855c87fd5e8 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sat, 28 Sep 2024 17:04:52 +1200 Subject: [PATCH] Relay links now jump to your relay config page for that relay --- gossip-bin/src/ui/feed/note/content.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gossip-bin/src/ui/feed/note/content.rs b/gossip-bin/src/ui/feed/note/content.rs index 5dea99053..718f2ec5f 100644 --- a/gossip-bin/src/ui/feed/note/content.rs +++ b/gossip-bin/src/ui/feed/note/content.rs @@ -7,7 +7,7 @@ use egui::{Button, Color32, Pos2, RichText, Stroke, Ui}; use gossip_lib::comms::ToOverlordMessage; use gossip_lib::FeedKind; use gossip_lib::GLOBALS; -use nostr_types::{ContentSegment, Id, IdHex, NAddr, NostrBech32, PublicKey, Span, Url}; +use nostr_types::{ContentSegment, Id, IdHex, NAddr, NostrBech32, PublicKey, RelayUrl, Span, Url}; use std::{ cell::{Ref, RefCell}, rc::Rc, @@ -204,6 +204,11 @@ pub(super) fn render_hyperlink( ) { let link = note.shattered_content.slice(linkspan).unwrap(); + if let Ok(relay_url) = RelayUrl::try_from_str(link) { + render_relay_link(app, ui, relay_url); + return; + } + // In DMs, fetching an image allows someone to associate your pubkey with your IP address // by controlling the image URL, and since only you see the URL it must have been you let privacy_issue = note.direct_message; @@ -274,6 +279,12 @@ pub(super) fn render_profile_link(app: &mut GossipUi, ui: &mut Ui, pubkey: &Publ }; } +pub fn render_relay_link(app: &mut GossipUi, ui: &mut Ui, relay_url: RelayUrl) { + if ui.link(relay_url.as_str()).clicked() { + app.set_page(ui.ctx(), Page::RelaysKnownNetwork(Some(relay_url))); + }; +} + pub(super) fn render_event_link( app: &mut GossipUi, ui: &mut Ui,