Skip to content

Commit

Permalink
Fix wizard panic on deleting purplepag.es
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedilger committed Oct 18, 2023
1 parent 204bb4c commit a67cb7c
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions gossip-bin/src/ui/wizard/setup_relays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,12 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
.cloned()
.collect();

let mut discovery_relays: Vec<Relay> = relays
let discovery_relays: Vec<Relay> = relays
.iter()
.filter(|relay| relay.has_usage_bits(Relay::DISCOVER))
.cloned()
.collect();

if !discovery_relays
.iter()
.any(|r| r.url.as_str() == "wss://purplepag.es/")
{
let mut purple_pages = read_relay(&RelayUrl::try_from_str("wss://purplepag.es/").unwrap());
purple_pages.set_usage_bits(Relay::DISCOVER);
let _ = GLOBALS.storage.write_relay(&purple_pages, None);
discovery_relays.push(purple_pages);
}

let mut need_more = false;

ui.add_space(20.0);
Expand Down Expand Up @@ -141,7 +131,9 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
for relay in discovery_relays.iter() {
ui.horizontal(|ui| {
if ui.button("🗑").clicked() {
unimplemented!();
let mut r = relay.clone();
r.clear_usage_bits(Relay::DISCOVER | Relay::ADVERTISE);
let _ = GLOBALS.storage.write_relay(&r, None);
}
ui.label(relay.url.as_str());
});
Expand Down

0 comments on commit a67cb7c

Please sign in to comment.