mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Updates for upstream nostr-types
This commit is contained in:
parent
be813f47d5
commit
bec63b1c09
@ -798,7 +798,7 @@ impl Overlord {
|
||||
marker: None,
|
||||
},
|
||||
Tag::Pubkey {
|
||||
pubkey,
|
||||
pubkey: pubkey.into(),
|
||||
recommended_relay_url: None,
|
||||
petname: None,
|
||||
},
|
||||
|
@ -3,7 +3,7 @@ use crate::error::Error;
|
||||
use crate::globals::GLOBALS;
|
||||
use dashmap::{DashMap, DashSet};
|
||||
use image::RgbaImage;
|
||||
use nostr_types::{Metadata, PublicKey, PublicKeyHex, Unixtime, Url};
|
||||
use nostr_types::{Metadata, PublicKeyHex, Unixtime, Url};
|
||||
use std::cmp::Ordering;
|
||||
use std::time::Duration;
|
||||
use tokio::task;
|
||||
@ -338,7 +338,7 @@ impl People {
|
||||
|
||||
/// This lets you start typing a name, and autocomplete the results for tagging
|
||||
/// someone in a post. It returns maximum 10 results.
|
||||
pub fn get_ids_from_prefix(&self, mut prefix: &str) -> Vec<(String, PublicKey)> {
|
||||
pub fn get_ids_from_prefix(&self, mut prefix: &str) -> Vec<(String, PublicKeyHex)> {
|
||||
// work with or without the @ symbol:
|
||||
if prefix.starts_with('@') {
|
||||
prefix = &prefix[1..]
|
||||
@ -348,8 +348,7 @@ impl People {
|
||||
.filter_map(|person| {
|
||||
if let Some(name) = &person.name {
|
||||
if name.starts_with(prefix) {
|
||||
let pubkey = PublicKey::try_from_hex_string(&person.pubkey).unwrap(); // FIXME
|
||||
return Some((name.clone(), pubkey));
|
||||
return Some((name.clone(), person.pubkey.clone()));
|
||||
}
|
||||
}
|
||||
None
|
||||
|
@ -110,7 +110,7 @@ pub async fn process_new_event(
|
||||
// upsert person_relay.last_suggested_bytag
|
||||
let now = Unixtime::now()?.0 as u64;
|
||||
DbPersonRelay::upsert_last_suggested_bytag(
|
||||
pubkey.as_hex_string(),
|
||||
pubkey.0.to_owned(),
|
||||
url.inner().to_owned(),
|
||||
now,
|
||||
)
|
||||
@ -211,7 +211,7 @@ pub async fn process_new_event(
|
||||
// 'p' tags represent the author's contacts
|
||||
for tag in &event.tags {
|
||||
if let Tag::Pubkey { pubkey, .. } = tag {
|
||||
pubkeys.push((*pubkey).into());
|
||||
pubkeys.push(pubkey.to_owned());
|
||||
// FIXME do something with recommended_relay_url and petname
|
||||
}
|
||||
}
|
||||
|
@ -211,13 +211,13 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
||||
for (i, tag) in app.draft_tags.iter().enumerate() {
|
||||
let rendered = match tag {
|
||||
Tag::Pubkey { pubkey, .. } => {
|
||||
if let Some(person) = GLOBALS.people.get(&(*pubkey).into()) {
|
||||
if let Some(person) = GLOBALS.people.get(pubkey) {
|
||||
match person.name {
|
||||
Some(name) => name,
|
||||
None => GossipUi::pubkey_long(pubkey),
|
||||
None => pubkey.0.clone(),
|
||||
}
|
||||
} else {
|
||||
GossipUi::pubkey_long(pubkey)
|
||||
pubkey.0.clone()
|
||||
}
|
||||
}
|
||||
_ => serde_json::to_string(tag).unwrap(),
|
||||
@ -521,7 +521,7 @@ fn render_post_actual(
|
||||
|
||||
// Add a 'p' tag for the author we are replying to
|
||||
app.draft_tags.push(Tag::Pubkey {
|
||||
pubkey: event.pubkey,
|
||||
pubkey: event.pubkey.into(),
|
||||
recommended_relay_url: None, // FIXME
|
||||
petname: None,
|
||||
});
|
||||
@ -531,7 +531,7 @@ fn render_post_actual(
|
||||
.tags
|
||||
.iter()
|
||||
.filter(|t| match t {
|
||||
Tag::Pubkey { pubkey, .. } => *pubkey != event.pubkey,
|
||||
Tag::Pubkey { pubkey, .. } => *pubkey != event.pubkey.into(),
|
||||
_ => false,
|
||||
})
|
||||
.map(|t| t.to_owned())
|
||||
@ -600,16 +600,15 @@ fn render_content(app: &mut GossipUi, ui: &mut Ui, tag_re: ®ex::Regex, event:
|
||||
if let Some(tag) = event.tags.get(num) {
|
||||
match tag {
|
||||
Tag::Pubkey { pubkey, .. } => {
|
||||
let pkhex: PublicKeyHex = (*pubkey).into();
|
||||
let nam = match GLOBALS.people.get(&pkhex) {
|
||||
let nam = match GLOBALS.people.get(pubkey) {
|
||||
Some(p) => match p.name {
|
||||
Some(n) => format!("@{}", n),
|
||||
None => format!("@{}", GossipUi::hex_pubkey_short(&pkhex)),
|
||||
None => format!("@{}", GossipUi::hex_pubkey_short(pubkey)),
|
||||
},
|
||||
None => format!("@{}", GossipUi::hex_pubkey_short(&pkhex)),
|
||||
None => format!("@{}", GossipUi::hex_pubkey_short(pubkey)),
|
||||
};
|
||||
if ui.link(&nam).clicked() {
|
||||
set_person_view(app, &pkhex);
|
||||
set_person_view(app, pubkey);
|
||||
};
|
||||
}
|
||||
Tag::Event { id, .. } => {
|
||||
|
Loading…
Reference in New Issue
Block a user