Account switcher

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2024-05-24 16:46:37 -04:00
committed by William Casarin
parent f489ed3b9e
commit c0b1a01b5d
8 changed files with 257 additions and 95 deletions

View File

@@ -87,10 +87,22 @@ impl AccountManager {
self.accounts.len()
}
pub fn get_currently_selected_account(&self) -> Option<usize> {
pub fn get_selected_account_index(&self) -> Option<usize> {
self.currently_selected_account
}
pub fn get_selected_account(&self) -> Option<&UserAccount> {
if let Some(account_index) = self.currently_selected_account {
if let Some(account) = self.get_account(account_index) {
Some(account)
} else {
None
}
} else {
None
}
}
pub fn select_account(&mut self, index: usize) {
if self.accounts.get(index).is_some() {
self.currently_selected_account = Some(index)