Updates for upstream nostr-types

This commit is contained in:
Mike Dilger 2023-01-14 12:35:21 +13:00
parent be813f47d5
commit bec63b1c09
4 changed files with 15 additions and 17 deletions

View File

@ -798,7 +798,7 @@ impl Overlord {
marker: None, marker: None,
}, },
Tag::Pubkey { Tag::Pubkey {
pubkey, pubkey: pubkey.into(),
recommended_relay_url: None, recommended_relay_url: None,
petname: None, petname: None,
}, },

View File

@ -3,7 +3,7 @@ use crate::error::Error;
use crate::globals::GLOBALS; use crate::globals::GLOBALS;
use dashmap::{DashMap, DashSet}; use dashmap::{DashMap, DashSet};
use image::RgbaImage; use image::RgbaImage;
use nostr_types::{Metadata, PublicKey, PublicKeyHex, Unixtime, Url}; use nostr_types::{Metadata, PublicKeyHex, Unixtime, Url};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::time::Duration; use std::time::Duration;
use tokio::task; use tokio::task;
@ -338,7 +338,7 @@ impl People {
/// This lets you start typing a name, and autocomplete the results for tagging /// This lets you start typing a name, and autocomplete the results for tagging
/// someone in a post. It returns maximum 10 results. /// 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: // work with or without the @ symbol:
if prefix.starts_with('@') { if prefix.starts_with('@') {
prefix = &prefix[1..] prefix = &prefix[1..]
@ -348,8 +348,7 @@ impl People {
.filter_map(|person| { .filter_map(|person| {
if let Some(name) = &person.name { if let Some(name) = &person.name {
if name.starts_with(prefix) { if name.starts_with(prefix) {
let pubkey = PublicKey::try_from_hex_string(&person.pubkey).unwrap(); // FIXME return Some((name.clone(), person.pubkey.clone()));
return Some((name.clone(), pubkey));
} }
} }
None None

View File

@ -110,7 +110,7 @@ pub async fn process_new_event(
// upsert person_relay.last_suggested_bytag // upsert person_relay.last_suggested_bytag
let now = Unixtime::now()?.0 as u64; let now = Unixtime::now()?.0 as u64;
DbPersonRelay::upsert_last_suggested_bytag( DbPersonRelay::upsert_last_suggested_bytag(
pubkey.as_hex_string(), pubkey.0.to_owned(),
url.inner().to_owned(), url.inner().to_owned(),
now, now,
) )
@ -211,7 +211,7 @@ pub async fn process_new_event(
// 'p' tags represent the author's contacts // 'p' tags represent the author's contacts
for tag in &event.tags { for tag in &event.tags {
if let Tag::Pubkey { pubkey, .. } = tag { if let Tag::Pubkey { pubkey, .. } = tag {
pubkeys.push((*pubkey).into()); pubkeys.push(pubkey.to_owned());
// FIXME do something with recommended_relay_url and petname // FIXME do something with recommended_relay_url and petname
} }
} }

View File

@ -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() { for (i, tag) in app.draft_tags.iter().enumerate() {
let rendered = match tag { let rendered = match tag {
Tag::Pubkey { pubkey, .. } => { Tag::Pubkey { pubkey, .. } => {
if let Some(person) = GLOBALS.people.get(&(*pubkey).into()) { if let Some(person) = GLOBALS.people.get(pubkey) {
match person.name { match person.name {
Some(name) => name, Some(name) => name,
None => GossipUi::pubkey_long(pubkey), None => pubkey.0.clone(),
} }
} else { } else {
GossipUi::pubkey_long(pubkey) pubkey.0.clone()
} }
} }
_ => serde_json::to_string(tag).unwrap(), _ => 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 // Add a 'p' tag for the author we are replying to
app.draft_tags.push(Tag::Pubkey { app.draft_tags.push(Tag::Pubkey {
pubkey: event.pubkey, pubkey: event.pubkey.into(),
recommended_relay_url: None, // FIXME recommended_relay_url: None, // FIXME
petname: None, petname: None,
}); });
@ -531,7 +531,7 @@ fn render_post_actual(
.tags .tags
.iter() .iter()
.filter(|t| match t { .filter(|t| match t {
Tag::Pubkey { pubkey, .. } => *pubkey != event.pubkey, Tag::Pubkey { pubkey, .. } => *pubkey != event.pubkey.into(),
_ => false, _ => false,
}) })
.map(|t| t.to_owned()) .map(|t| t.to_owned())
@ -600,16 +600,15 @@ fn render_content(app: &mut GossipUi, ui: &mut Ui, tag_re: &regex::Regex, event:
if let Some(tag) = event.tags.get(num) { if let Some(tag) = event.tags.get(num) {
match tag { match tag {
Tag::Pubkey { pubkey, .. } => { Tag::Pubkey { pubkey, .. } => {
let pkhex: PublicKeyHex = (*pubkey).into(); let nam = match GLOBALS.people.get(pubkey) {
let nam = match GLOBALS.people.get(&pkhex) {
Some(p) => match p.name { Some(p) => match p.name {
Some(n) => format!("@{}", n), 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() { if ui.link(&nam).clicked() {
set_person_view(app, &pkhex); set_person_view(app, pubkey);
}; };
} }
Tag::Event { id, .. } => { Tag::Event { id, .. } => {