fix (status): updating status from 'app.init_account()'

This commit is contained in:
antifallobst 2023-07-06 17:34:55 +02:00
parent b1c0007098
commit a7e11c6ac0
2 changed files with 16 additions and 2 deletions

View File

@ -131,6 +131,12 @@ impl App<'_> {
tokio::task::spawn(event::poll_matrix_events(self.channel_tx.clone(), self.matrix_listener_killer.clone(), client)); tokio::task::spawn(event::poll_matrix_events(self.channel_tx.clone(), self.matrix_listener_killer.clone(), client));
let account = self.account()?;
let name = account.name().clone();
let user_id = account.user_id().clone();
self.status.set_account_name(name);
self.status.set_account_user_id(user_id);
info!("Initializing client for the current account"); info!("Initializing client for the current account");
Ok(()) Ok(())
@ -151,10 +157,10 @@ impl App<'_> {
None None
} }
pub fn account(&self) -> Result<&Account, ()> { pub fn account(&self) -> Result<&Account> {
let account = self.accounts_manager.current(); let account = self.accounts_manager.current();
match account { match account {
None => Err(()), None => Err(Error::msg("failed to resolve current account")),
Some(a) => Ok(a) Some(a) => Ok(a)
} }
} }

View File

@ -28,10 +28,18 @@ impl Status {
&self.account_name &self.account_name
} }
pub fn set_account_name(&mut self, name: String) {
self.account_name = name;
}
pub fn account_user_id(&self) -> &String { pub fn account_user_id(&self) -> &String {
&self.account_user_id &self.account_user_id
} }
pub fn set_account_user_id(&mut self, user_id: String) {
self.account_user_id = user_id;
}
pub fn room(&self) -> Option<()> { pub fn room(&self) -> Option<()> {
None None
} }