implement stateful account management view

`./preview StatefulAccountManagementView`

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-09-09 18:31:05 -04:00
committed by William Casarin
parent 3a9c7607f3
commit 950a47119e
5 changed files with 166 additions and 10 deletions

View File

@@ -1,11 +1,13 @@
use std::cmp::Ordering;
use enostr::{FilledKeypair, Keypair};
use enostr::{FilledKeypair, FullKeypair, Keypair};
pub use crate::user_account::UserAccount;
use crate::{
key_storage::{KeyStorage, KeyStorageResponse, KeyStorageType},
ui::account_management::AccountManagementViewResponse,
ui::{
account_login_view::AccountLoginResponse, account_management::AccountManagementViewResponse,
},
};
use tracing::info;
@@ -120,7 +122,7 @@ impl AccountManager {
}
}
pub fn process_view_response(
pub fn process_management_view_response_stateless(
manager: &mut AccountManager,
response: AccountManagementViewResponse,
) {
@@ -131,5 +133,17 @@ pub fn process_view_response(
AccountManagementViewResponse::SelectAccount(index) => {
manager.select_account(index);
}
AccountManagementViewResponse::RouteToLogin => {}
}
}
pub fn process_login_view_response(manager: &mut AccountManager, response: AccountLoginResponse) {
match response {
AccountLoginResponse::CreateNew => {
manager.add_account(FullKeypair::generate().to_keypair());
}
AccountLoginResponse::LoginWith(keypair) => {
manager.add_account(keypair);
}
}
}