Offer data as nostr urls instead of bech32 strings

This commit is contained in:
Mike Dilger 2023-07-09 08:56:34 +12:00
parent 4491076e3d
commit abe1c01d0d
3 changed files with 13 additions and 9 deletions

View File

@ -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<Tag>,
reply_to: Option<Id>,
) -> Result<(), Error> {

View File

@ -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;

View File

@ -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();
}
}