From ac245a6cb27fd25ea731fe2481951d213d2d76ce Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Sat, 7 Aug 2021 21:39:48 +0200 Subject: [PATCH] accounts: add `get_selected_account_id` function --- src/accounts.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/accounts.rs b/src/accounts.rs index 3ce57eb14..949ea7fa1 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -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 { + 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?;