mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
parent
3ed87aae05
commit
a2a708f1ae
7 changed files with 271 additions and 64 deletions
25
src/main.rs
25
src/main.rs
|
@ -27,17 +27,10 @@ use std::sync::Arc;
|
|||
use std::time::Duration;
|
||||
|
||||
use clap::Parser;
|
||||
use matrix_sdk::ruma::OwnedUserId;
|
||||
use tokio::sync::Mutex as AsyncMutex;
|
||||
use tracing_subscriber::FmtSubscriber;
|
||||
|
||||
use matrix_sdk::{
|
||||
config::SyncSettings,
|
||||
ruma::{
|
||||
api::client::filter::{FilterDefinition, LazyLoadOptions, RoomEventFilter, RoomFilter},
|
||||
OwnedUserId,
|
||||
},
|
||||
};
|
||||
|
||||
use modalkit::crossterm::{
|
||||
self,
|
||||
cursor::Show as CursorShow,
|
||||
|
@ -719,20 +712,6 @@ async fn login(worker: Requester, settings: &ApplicationSettings) -> IambResult<
|
|||
}
|
||||
}
|
||||
|
||||
// Perform an initial, lazily-loaded sync.
|
||||
let mut room = RoomEventFilter::default();
|
||||
room.lazy_load_options = LazyLoadOptions::Enabled { include_redundant_members: false };
|
||||
|
||||
let mut room_ev = RoomFilter::default();
|
||||
room_ev.state = room;
|
||||
|
||||
let mut filter = FilterDefinition::default();
|
||||
filter.room = room_ev;
|
||||
|
||||
let settings = SyncSettings::new().filter(filter.into());
|
||||
|
||||
worker.client.sync_once(settings).await.map_err(IambError::from)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -744,12 +723,14 @@ fn print_exit<T: Display, N>(v: T) -> N {
|
|||
async fn run(settings: ApplicationSettings) -> IambResult<()> {
|
||||
// Set up the async worker thread and global store.
|
||||
let worker = ClientWorker::spawn(settings.clone()).await;
|
||||
let client = worker.client.clone();
|
||||
let store = ChatStore::new(worker.clone(), settings.clone());
|
||||
let store = Store::new(store);
|
||||
let store = Arc::new(AsyncMutex::new(store));
|
||||
worker.init(store.clone());
|
||||
|
||||
login(worker, &settings).await.unwrap_or_else(print_exit);
|
||||
worker::do_first_sync(client, &store).await;
|
||||
|
||||
fn restore_tty() {
|
||||
let _ = crossterm::terminal::disable_raw_mode();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue