From abe1c01d0d17e434503d3f687190818e02af0ee2 Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Sun, 9 Jul 2023 08:56:34 +1200 Subject: [PATCH] Offer data as nostr urls instead of bech32 strings --- src/overlord/mod.rs | 6 +++--- src/ui/feed/note/mod.rs | 11 +++++++---- src/ui/feed/post.rs | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/overlord/mod.rs b/src/overlord/mod.rs index 895c147a..1935931c 100644 --- a/src/overlord/mod.rs +++ b/src/overlord/mod.rs @@ -17,8 +17,8 @@ use http::StatusCode; use minion::Minion; use nostr_types::{ EncryptedPrivateKey, Event, EventKind, Filter, Id, IdHex, IdHexPrefix, Metadata, MilliSatoshi, - NostrBech32, NostrUrl, PayRequestData, PreEvent, PrivateKey, Profile, PublicKey, PublicKeyHex, - RelayUrl, Tag, UncheckedUrl, Unixtime, + NostrBech32, PayRequestData, PreEvent, PrivateKey, Profile, PublicKey, PublicKeyHex, RelayUrl, + Tag, UncheckedUrl, Unixtime, }; use std::collections::HashMap; use std::sync::atomic::Ordering; @@ -1017,7 +1017,7 @@ impl Overlord { async fn post( &mut self, - mut content: String, + content: String, mut tags: Vec, reply_to: Option, ) -> Result<(), Error> { diff --git a/src/ui/feed/note/mod.rs b/src/ui/feed/note/mod.rs index 3e437e02..cb010e0d 100644 --- a/src/ui/feed/note/mod.rs +++ b/src/ui/feed/note/mod.rs @@ -19,7 +19,7 @@ use egui::{ Align, Context, Frame, Image, Label, Layout, RichText, Sense, Separator, Stroke, TextStyle, Ui, Vec2, }; -use nostr_types::{Event, EventDelegation, EventKind, EventPointer, IdHex, UncheckedUrl}; +use nostr_types::{Event, EventDelegation, EventKind, EventPointer, IdHex, NostrUrl, UncheckedUrl}; pub struct NoteRenderData { /// Available height for post @@ -356,10 +356,12 @@ fn render_note_inner( author: None, kind: None, }; - ui.output_mut(|o| o.copied_text = event_pointer.as_bech32_string()); + let nostr_url: NostrUrl = event_pointer.into(); + ui.output_mut(|o| o.copied_text = format!("{}", nostr_url)); } if ui.button("Copy note1 Id").clicked() { - ui.output_mut(|o| o.copied_text = note.event.id.as_bech32_string()); + let nostr_url: NostrUrl = note.event.id.into(); + ui.output_mut(|o| o.copied_text = format!("{}", nostr_url)); } if ui.button("Copy hex Id").clicked() { ui.output_mut(|o| o.copied_text = note.event.id.as_hex_string()); @@ -596,7 +598,8 @@ fn render_note_inner( author: None, kind: None, }; - app.draft.push_str(&event_pointer.as_bech32_string()); + let nostr_url: NostrUrl = event_pointer.into(); + app.draft.push_str(&format!("{}", nostr_url)); app.draft_repost = None; app.replying_to = None; app.show_post_area = true; diff --git a/src/ui/feed/post.rs b/src/ui/feed/post.rs index cdd54061..227b44b7 100644 --- a/src/ui/feed/post.rs +++ b/src/ui/feed/post.rs @@ -7,7 +7,7 @@ use eframe::egui; use eframe::epaint::text::LayoutJob; use egui::{Align, Context, Key, Layout, Modifiers, RichText, ScrollArea, Ui, Vec2}; use memoize::memoize; -use nostr_types::{find_nostr_bech32_pos, NostrBech32, Tag}; +use nostr_types::{find_nostr_bech32_pos, NostrBech32, NostrUrl, Tag}; #[memoize] pub fn textarea_highlighter(theme: Theme, text: String) -> LayoutJob { @@ -230,7 +230,8 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram if !app.draft.ends_with(' ') && !app.draft.is_empty() { app.draft.push(' '); } - app.draft.push_str(&pair.1.as_bech32_string()); + let nostr_url: NostrUrl = pair.1.into(); + app.draft.push_str(&format!("{}", nostr_url)); app.tag_someone = "".to_owned(); } }