add ability to delete keypairs from settings menu
This commit is contained in:
parent
2f1ebee787
commit
0d4cdf851e
2 changed files with 15 additions and 1 deletions
|
@ -28,6 +28,15 @@ impl AccountManager {
|
|||
Ok(keys)
|
||||
}
|
||||
|
||||
pub fn delete_key(&mut self, key: &Keys) -> Result<(), Error> {
|
||||
self.remove_key(key)?;
|
||||
if let Some(index) = self.loaded_keys.iter().position(|k| k == key) {
|
||||
self.loaded_keys.remove(index);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_platform_keystorage() -> KeyStorageType {
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
|
|
|
@ -286,7 +286,12 @@ fn render_app(app: &mut Hoot, ctx: &egui::Context) {
|
|||
ui.vertical(|ui| {
|
||||
use nostr::ToBech32;
|
||||
for key in app.account_manager.loaded_keys.clone() {
|
||||
ui.label(format!("Key ID: {}", key.public_key().to_bech32().unwrap()));
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(format!("Key ID: {}", key.public_key().to_bech32().unwrap()));
|
||||
if ui.button("Remove Key").clicked() {
|
||||
let _ = app.account_manager.delete_key(&key);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue