fix some clippy warnings
This commit is contained in:
parent
59084e93ea
commit
4711fc5b0b
6 changed files with 62 additions and 50 deletions
|
@ -130,7 +130,8 @@ pub async fn sync_main(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
while let Some((uid, attrs)) = message_list.next().await {
|
while let Some((uid, attrs)) = message_list.next().await {
|
||||||
let evt = MailEvent::UpdateUid(acct_name.clone(), uid, attrs);
|
let evt = MailEvent::UpdateUid(acct_name.clone(), uid, attrs);
|
||||||
mail2ui_tx.send(evt);
|
// TODO: probably odn't care about this?
|
||||||
|
let _ = mail2ui_tx.send(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if IDLE is supported
|
// check if IDLE is supported
|
||||||
|
|
|
@ -63,10 +63,9 @@ pub enum MailStoreUpdate {
|
||||||
|
|
||||||
impl MailStore {
|
impl MailStore {
|
||||||
/// Creates a new MailStore
|
/// Creates a new MailStore
|
||||||
pub fn new(mut config_watcher: ConfigWatcher) -> Self {
|
pub fn new(config_watcher: ConfigWatcher) -> Self {
|
||||||
let config = Arc::new(RwLock::new(None));
|
let config = Arc::new(RwLock::new(None));
|
||||||
let config2 = config.clone();
|
let config2 = config.clone();
|
||||||
|
|
||||||
let inner = Arc::new(RwLock::new(None));
|
let inner = Arc::new(RwLock::new(None));
|
||||||
let inner2 = inner.clone();
|
let inner2 = inner.clone();
|
||||||
|
|
||||||
|
@ -74,35 +73,14 @@ impl MailStore {
|
||||||
let store_out_tx = Arc::new(store_out_tx);
|
let store_out_tx = Arc::new(store_out_tx);
|
||||||
let store_out_tx2 = store_out_tx.clone();
|
let store_out_tx2 = store_out_tx.clone();
|
||||||
|
|
||||||
let listener = async move {
|
let handle = tokio::spawn(async move {
|
||||||
while let Ok(()) = config_watcher.changed().await {
|
match mail_store_config_listener(config_watcher, config2, inner2, store_out_tx2).await {
|
||||||
let new_config = config_watcher.borrow().clone();
|
Ok(_) => {}
|
||||||
|
Err(e) => {
|
||||||
let fut = future::try_join(
|
error!("mail store listener error: {}", e);
|
||||||
async {
|
}
|
||||||
let mut write = config2.write().await;
|
|
||||||
write.replace(new_config.clone());
|
|
||||||
Ok::<_, Error>(())
|
|
||||||
},
|
|
||||||
async {
|
|
||||||
let new_inner =
|
|
||||||
MailStoreInner::init_with_config(new_config.clone()).await?;
|
|
||||||
let mut write = inner2.write().await;
|
|
||||||
write.replace(new_inner);
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
match fut.await {
|
|
||||||
Ok(_) => store_out_tx2.send(Some(MailStoreUpdate::AccountListUpdate(()))),
|
|
||||||
Err(e) => {
|
|
||||||
error!("during mail loop: {}", e);
|
|
||||||
panic!();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
let handle = tokio::spawn(listener);
|
|
||||||
|
|
||||||
MailStore {
|
MailStore {
|
||||||
config,
|
config,
|
||||||
|
@ -297,6 +275,41 @@ impl MailStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn mail_store_config_listener(
|
||||||
|
mut config_watcher: ConfigWatcher,
|
||||||
|
config: Arc<RwLock<Option<Config>>>,
|
||||||
|
inner: Arc<RwLock<Option<MailStoreInner>>>,
|
||||||
|
store_out_tx: Arc<watch::Sender<Option<MailStoreUpdate>>>,
|
||||||
|
) -> Result<()> {
|
||||||
|
while let Ok(()) = config_watcher.changed().await {
|
||||||
|
let new_config = config_watcher.borrow().clone();
|
||||||
|
|
||||||
|
let fut = future::try_join(
|
||||||
|
async {
|
||||||
|
let mut write = config.write().await;
|
||||||
|
write.replace(new_config.clone());
|
||||||
|
Ok::<_, Error>(())
|
||||||
|
},
|
||||||
|
async {
|
||||||
|
let new_inner = MailStoreInner::init_with_config(new_config.clone()).await?;
|
||||||
|
let mut write = inner.write().await;
|
||||||
|
write.replace(new_inner);
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
match fut.await {
|
||||||
|
Ok(_) => store_out_tx.send(Some(MailStoreUpdate::AccountListUpdate(())))?,
|
||||||
|
Err(e) => {
|
||||||
|
error!("during mail loop: {}", e);
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
impl MailStoreInner {
|
impl MailStoreInner {
|
||||||
async fn init_with_config(config: Config) -> Result<Self> {
|
async fn init_with_config(config: Config) -> Result<Self> {
|
||||||
let data_dir = config.data_dir.to_string_lossy();
|
let data_dir = config.data_dir.to_string_lossy();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use gluon::{import::add_extern_module, ThreadExt};
|
use gluon::{import::add_extern_module, ThreadExt};
|
||||||
|
|
||||||
use crate::ui::{UiCommand, UiUpdate};
|
// use crate::ui::{UiCommand, UiUpdate};
|
||||||
|
|
||||||
/// Creates a VM for running scripts
|
/// Creates a VM for running scripts
|
||||||
pub async fn create_script_vm() -> Result<()> {
|
pub async fn create_script_vm() -> Result<()> {
|
||||||
|
|
|
@ -10,5 +10,7 @@ pub struct SearchIndex {}
|
||||||
|
|
||||||
impl SearchIndex {
|
impl SearchIndex {
|
||||||
/// Create a new instance of the search index
|
/// Create a new instance of the search index
|
||||||
pub fn new(config: Config) {}
|
pub fn new(config: Config) -> Self {
|
||||||
|
SearchIndex {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
mod colon_prompt;
|
mod colon_prompt;
|
||||||
mod input;
|
mod input;
|
||||||
mod keybinds;
|
// mod keybinds;
|
||||||
mod mail_view;
|
mod mail_view;
|
||||||
mod messages;
|
// mod messages;
|
||||||
mod windows;
|
mod windows;
|
||||||
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
|
@ -45,7 +45,7 @@ use crate::mail::{EmailMetadata, MailEvent, MailStore};
|
||||||
use self::colon_prompt::ColonPrompt;
|
use self::colon_prompt::ColonPrompt;
|
||||||
use self::input::{BaseInputHandler, HandlesInput, InputResult};
|
use self::input::{BaseInputHandler, HandlesInput, InputResult};
|
||||||
use self::mail_view::MailView;
|
use self::mail_view::MailView;
|
||||||
pub(crate) use self::messages::*;
|
// pub(crate) use self::messages::*;
|
||||||
use self::windows::*;
|
use self::windows::*;
|
||||||
|
|
||||||
pub(crate) type FrameType<'a, 'b> = Frame<'a, &'b mut Stdout>;
|
pub(crate) type FrameType<'a, 'b> = Frame<'a, &'b mut Stdout>;
|
||||||
|
@ -115,7 +115,7 @@ pub async fn run_ui2(params: UiParams) -> Result<()> {
|
||||||
// got an event from the ui thread
|
// got an event from the ui thread
|
||||||
evt = ui_events.next().fuse() => if let Some(evt) = evt {
|
evt = ui_events.next().fuse() => if let Some(evt) = evt {
|
||||||
let evt = evt?;
|
let evt = evt?;
|
||||||
ui.process_event(evt)?;
|
ui.process_event(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for approx 60fps
|
// wait for approx 60fps
|
||||||
|
@ -169,7 +169,7 @@ impl UI {
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(|| i.to_string())
|
.unwrap_or_else(|| i.to_string())
|
||||||
})
|
})
|
||||||
.map(|s| Spans::from(s))
|
.map(Spans::from)
|
||||||
.collect();
|
.collect();
|
||||||
let tabs = Tabs::new(titles).style(Style::default().bg(Color::DarkGray));
|
let tabs = Tabs::new(titles).style(Style::default().bg(Color::DarkGray));
|
||||||
f.render_widget(tabs, chunks[1]);
|
f.render_widget(tabs, chunks[1]);
|
||||||
|
@ -196,7 +196,7 @@ impl UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Main entrypoint for handling any kind of event coming from the terminal
|
/// Main entrypoint for handling any kind of event coming from the terminal
|
||||||
fn process_event(&mut self, evt: Event) -> Result<()> {
|
fn process_event(&mut self, evt: Event) {
|
||||||
if let Event::Key(evt) = evt {
|
if let Event::Key(evt) = evt {
|
||||||
if let KeyEvent {
|
if let KeyEvent {
|
||||||
code: KeyCode::Char('q'),
|
code: KeyCode::Char('q'),
|
||||||
|
@ -208,7 +208,7 @@ impl UI {
|
||||||
|
|
||||||
// handle states in the state stack
|
// handle states in the state stack
|
||||||
// although this is written in a for loop, every case except one should break
|
// although this is written in a for loop, every case except one should break
|
||||||
// let mut should_pop = false;
|
let should_pop = false;
|
||||||
// for input_state in input_states.iter_mut().rev() {
|
// for input_state in input_states.iter_mut().rev() {
|
||||||
// match input_state.handle_key(&mut term, evt)? {
|
// match input_state.handle_key(&mut term, evt)? {
|
||||||
// InputResult::Ok => break,
|
// InputResult::Ok => break,
|
||||||
|
@ -223,12 +223,11 @@ impl UI {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// if should_pop {
|
if should_pop {
|
||||||
// input_states.pop();
|
debug!("pop state");
|
||||||
// }
|
// input_states.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn process_mail_event(&mut self, evt: MailEvent) -> Result<()> {
|
async fn process_mail_event(&mut self, evt: MailEvent) -> Result<()> {
|
||||||
|
|
|
@ -53,7 +53,7 @@ impl WindowLayout {
|
||||||
self.page_order.push(pid);
|
self.page_order.push(pid);
|
||||||
self.ids.insert(id, pid);
|
self.ids.insert(id, pid);
|
||||||
|
|
||||||
if let None = self.currently_active {
|
if self.currently_active.is_none() {
|
||||||
self.currently_active = Some(id);
|
self.currently_active = Some(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,7 @@ struct PageGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Dir {
|
enum Dir {}
|
||||||
H,
|
|
||||||
V,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PageGraph {
|
impl PageGraph {
|
||||||
pub fn new(id: LayoutId) -> Self {
|
pub fn new(id: LayoutId) -> Self {
|
||||||
|
|
Loading…
Reference in a new issue