Keep hold of the Accounts struct

This commit is contained in:
2021-10-31 01:31:02 +01:00
parent f57cdf3cdc
commit e99d824227

View File

@@ -39,11 +39,12 @@ pub fn run(tx: FdSender<SystemMessage>, rx: Receiver<PurpleMessage>) {
pub struct DeltaSystem {
tx: FdSender<SystemMessage>,
rx: Receiver<PurpleMessage>,
accounts: Option<Accounts>,
}
impl DeltaSystem {
fn new(tx: FdSender<SystemMessage>, rx: Receiver<PurpleMessage>) -> Self {
Self { tx, rx }
Self { tx, rx, accounts: None }
}
fn user_dir() -> async_std::path::PathBuf {
@@ -62,7 +63,7 @@ impl DeltaSystem {
let mut config_dir = DeltaSystem::user_dir();
config_dir.push("purple-plugin-delta");
Accounts::new("purple-plugin-delta".into(), config_dir).await.unwrap();
self.accounts = Some(Accounts::new("purple-plugin-delta".into(), config_dir).await.unwrap());
log::info!("Looping on messages");
loop {
@@ -84,6 +85,7 @@ impl DeltaSystem {
if let Err(error) = result {
log::error!("Error handling message: {}", error);
}
logging::flush();
}
}