Render display_name instead of name (if set in metadata)

This commit is contained in:
Mike Dilger 2023-02-10 03:06:20 +13:00
parent a21e48d597
commit 6265e47886
2 changed files with 16 additions and 1 deletions

View File

@ -46,6 +46,21 @@ impl DbPerson {
}
}
pub fn display_name(&self) -> Option<&str> {
if let Some(md) = &self.metadata {
if md.other.contains_key("display_name") {
if let Some(serde_json::Value::String(s)) = md.other.get("display_name") {
if !s.is_empty() {
return Some(s);
}
}
}
md.name.as_deref()
} else {
None
}
}
pub fn name(&self) -> Option<&str> {
if let Some(md) = &self.metadata {
md.name.as_deref()

View File

@ -461,7 +461,7 @@ impl GossipUi {
pub fn render_person_name_line(app: &mut GossipUi, ui: &mut Ui, person: &DbPerson) {
ui.horizontal_wrapped(|ui| {
let name = if let Some(name) = person.name() {
let name = if let Some(name) = person.display_name() {
name.to_owned()
} else {
GossipUi::pubkey_short(&person.pubkey)