mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
relays page: put your relays at the top
This commit is contained in:
parent
65306f93f3
commit
8593a4e4c7
@ -23,6 +23,8 @@ pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::F
|
||||
let mut relays: Vec<DbRelay> = relays.drain().map(|(_, relay)| relay).collect();
|
||||
relays.sort_by(|a, b| a.url.cmp(&b.url));
|
||||
|
||||
let postrelays: Vec<DbRelay> = relays.iter().filter(|r| r.post).map(|r| r.to_owned()).collect();
|
||||
|
||||
ui.add_space(32.0);
|
||||
|
||||
ui.with_layout(Layout::bottom_up(Align::Center), |ui| {
|
||||
@ -36,10 +38,35 @@ pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::F
|
||||
}
|
||||
|
||||
ui.with_layout(Layout::top_down(Align::Center), |ui| {
|
||||
|
||||
ui.heading("Your Relays (write):");
|
||||
|
||||
for relay in postrelays.iter() {
|
||||
render_relay(ui, relay, true);
|
||||
ui.add_space(3.0);
|
||||
ui.separator();
|
||||
ui.add_space(3.0);
|
||||
}
|
||||
|
||||
ui.heading("Known Relays:");
|
||||
|
||||
ScrollArea::vertical().show(ui, |ui| {
|
||||
for relay in relays.iter_mut() {
|
||||
render_relay(ui, relay, false);
|
||||
ui.add_space(3.0);
|
||||
ui.separator();
|
||||
ui.add_space(3.0);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn render_relay (ui: &mut Ui, relay: &DbRelay, bold: bool) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(&relay.url);
|
||||
let mut rt = RichText::new(&relay.url);
|
||||
if bold { rt = rt.strong(); }
|
||||
ui.label(rt);
|
||||
|
||||
ui.with_layout(Layout::right_to_left(Align::Center), |ui| {
|
||||
|
||||
@ -60,11 +87,4 @@ pub(super) fn update(_app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::F
|
||||
//}
|
||||
});
|
||||
});
|
||||
|
||||
ui.add_space(12.0);
|
||||
ui.separator();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user