accounts: add get_selected_account_id function

This commit is contained in:
Simon Laux
2021-08-07 21:39:48 +02:00
committed by GitHub
parent 126beb62f3
commit ac245a6cb2

View File

@@ -78,6 +78,14 @@ impl Accounts {
self.accounts.read().await.get(&id).cloned()
}
/// Returns the currently selected account's id or None if no account is selected.
pub async fn get_selected_account_id(&self) -> Option<u32> {
match self.config.get_selected_account().await {
0 => None,
id => Some(id),
}
}
/// Select the given account.
pub async fn select_account(&self, id: u32) -> Result<()> {
self.config.select_account(id).await?;