decouple RelayView UI from state mutation

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-07-01 15:09:10 -04:00
parent 10c4ac80a1
commit b41f4c3359
6 changed files with 53 additions and 115 deletions

View File

@@ -315,25 +315,21 @@ impl Accounts {
self.cache.get(pubkey).and_then(|r| r.key.to_full())
}
pub fn add_advertised_relay(&mut self, relay_to_add: &str, pool: &mut RelayPool) {
pub fn process_relay_action(
&mut self,
ctx: &egui::Context,
pool: &mut RelayPool,
action: RelayAction,
) {
let acc = self.cache.selected_mut();
modify_advertised_relays(
&acc.key,
RelayAction::Add(relay_to_add.to_owned()),
pool,
&self.relay_defaults,
&mut acc.data,
);
}
modify_advertised_relays(&acc.key, action, pool, &self.relay_defaults, &mut acc.data);
pub fn remove_advertised_relay(&mut self, relay_to_remove: &str, pool: &mut RelayPool) {
let acc = self.cache.selected_mut();
modify_advertised_relays(
&acc.key,
RelayAction::Remove(relay_to_remove.to_owned()),
update_relay_configuration(
pool,
&self.relay_defaults,
&mut acc.data,
&acc.key.pubkey,
&acc.data,
create_wakeup(ctx),
);
}
}

View File

@@ -34,6 +34,7 @@ mod wallet;
mod zaps;
pub use account::accounts::{AccountData, Accounts};
pub use account::relay::RelayAction;
pub use account::FALLBACK_PUBKEY;
pub use app::{App, AppAction, Notedeck};
pub use args::Args;