make AccountManagementView stateless

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-09-09 13:55:33 -04:00
committed by William Casarin
parent dda7256f51
commit 3a9c7607f3
3 changed files with 135 additions and 120 deletions

View File

@@ -2,8 +2,11 @@ use std::cmp::Ordering;
use enostr::{FilledKeypair, Keypair};
use crate::key_storage::{KeyStorage, KeyStorageResponse, KeyStorageType};
pub use crate::user_account::UserAccount;
use crate::{
key_storage::{KeyStorage, KeyStorageResponse, KeyStorageType},
ui::account_management::AccountManagementViewResponse,
};
use tracing::info;
/// The interface for managing the user's accounts.
@@ -116,3 +119,17 @@ impl AccountManager {
self.currently_selected_account = None
}
}
pub fn process_view_response(
manager: &mut AccountManager,
response: AccountManagementViewResponse,
) {
match response {
AccountManagementViewResponse::RemoveAccount(index) => {
manager.remove_account(index);
}
AccountManagementViewResponse::SelectAccount(index) => {
manager.select_account(index);
}
}
}