mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Avoid panic on person page for person we don't have in memory
This commit is contained in:
parent
a4d331533e
commit
9a9f359fba
@ -18,11 +18,13 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let person = maybe_person.as_ref().unwrap();
|
|
||||||
|
|
||||||
ui.add_space(24.0);
|
ui.add_space(24.0);
|
||||||
|
|
||||||
|
if let Some(person) = &maybe_person {
|
||||||
ui.heading(get_name(person));
|
ui.heading(get_name(person));
|
||||||
|
} else {
|
||||||
|
ui.heading(&pubkeyhex.0);
|
||||||
|
}
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
// Avatar first
|
// Avatar first
|
||||||
@ -32,23 +34,25 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
|||||||
app.placeholder_avatar.clone()
|
app.placeholder_avatar.clone()
|
||||||
};
|
};
|
||||||
ui.image(&avatar, Vec2 { x: 36.0, y: 36.0 });
|
ui.image(&avatar, Vec2 { x: 36.0, y: 36.0 });
|
||||||
|
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.label(RichText::new(GossipUi::hex_pubkey_short(&pubkeyhex)).weak());
|
ui.label(RichText::new(GossipUi::hex_pubkey_short(&pubkeyhex)).weak());
|
||||||
GossipUi::render_person_name_line(ui, Some(person));
|
GossipUi::render_person_name_line(ui, maybe_person.as_ref());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.add_space(12.0);
|
ui.add_space(12.0);
|
||||||
|
|
||||||
|
if let Some(person) = &maybe_person {
|
||||||
if let Some(about) = person.about.as_deref() {
|
if let Some(about) = person.about.as_deref() {
|
||||||
ui.label(about);
|
ui.label(about);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui.add_space(12.0);
|
ui.add_space(12.0);
|
||||||
|
|
||||||
|
if let Some(person) = &maybe_person {
|
||||||
#[allow(clippy::collapsible_else_if)]
|
#[allow(clippy::collapsible_else_if)]
|
||||||
if person.followed == 0 {
|
if maybe_person.is_none() || person.followed == 0 {
|
||||||
if ui.button("FOLLOW").clicked() {
|
if ui.button("FOLLOW").clicked() {
|
||||||
GLOBALS.people.follow(&pubkeyhex, true);
|
GLOBALS.people.follow(&pubkeyhex, true);
|
||||||
}
|
}
|
||||||
@ -57,6 +61,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
|||||||
GLOBALS.people.follow(&pubkeyhex, false);
|
GLOBALS.people.follow(&pubkeyhex, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ui.button("UPDATE METADATA").clicked() {
|
if ui.button("UPDATE METADATA").clicked() {
|
||||||
let _ = GLOBALS
|
let _ = GLOBALS
|
||||||
|
Loading…
Reference in New Issue
Block a user