2023-06-14 21:49:20 +00:00
|
|
|
mod ui;
|
2023-06-15 17:19:24 +00:00
|
|
|
mod accounts;
|
2023-06-15 22:15:07 +00:00
|
|
|
mod app;
|
2023-06-14 21:49:20 +00:00
|
|
|
|
2023-06-29 18:17:54 +00:00
|
|
|
use crate::ui::UI;
|
2023-06-15 19:57:43 +00:00
|
|
|
use matrix_sdk::ruma::exports::serde_json;
|
2023-06-15 17:19:24 +00:00
|
|
|
use tokio::time::{sleep, Duration};
|
2023-06-29 10:36:16 +00:00
|
|
|
use std::{io, thread};
|
2023-06-29 18:17:54 +00:00
|
|
|
use log::{error, warn, info, LevelFilter};
|
|
|
|
use log4rs::append::file::FileAppender;
|
|
|
|
use log4rs::encode::pattern::PatternEncoder;
|
|
|
|
use log4rs::config::{Appender, Config, Root};
|
2023-06-14 21:49:20 +00:00
|
|
|
|
2023-06-15 17:19:24 +00:00
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<()> {
|
2023-06-29 18:17:54 +00:00
|
|
|
let logfile = FileAppender::builder()
|
|
|
|
.encoder(Box::new(PatternEncoder::new("{l} - {m}\n")))
|
|
|
|
.build("userdata/output.log")?;
|
|
|
|
|
|
|
|
let config = Config::builder()
|
|
|
|
.appender(Appender::builder().build("logfile", Box::new(logfile)))
|
|
|
|
.build(Root::builder()
|
|
|
|
.appender("logfile")
|
|
|
|
.build(LevelFilter::Info))?;
|
|
|
|
|
|
|
|
log4rs::init_config(config)?;
|
2023-06-15 17:19:24 +00:00
|
|
|
|
2023-06-15 22:15:07 +00:00
|
|
|
let mut app = app::App::new();
|
2023-06-23 03:41:26 +00:00
|
|
|
app.fill_test_data();
|
2023-06-15 19:57:43 +00:00
|
|
|
|
2023-06-23 03:41:26 +00:00
|
|
|
let mut ui = UI::new();
|
2023-06-29 10:36:16 +00:00
|
|
|
if app.accounts_manager.num_accounts() == 0 {
|
2023-06-29 18:17:54 +00:00
|
|
|
info!("No saved sessions found -> jumping into setup");
|
2023-06-29 10:36:16 +00:00
|
|
|
ui.setup(&mut app).await?;
|
|
|
|
}
|
2023-06-15 19:57:43 +00:00
|
|
|
|
2023-06-29 10:36:16 +00:00
|
|
|
ui.main(&mut app).await?;
|
2023-06-14 21:49:20 +00:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|