commit 054852d93bacf21a31bb50486fcc5b78e5600136
parent 825a2cbff8728a3071a2b879f26e0f9d4e4d3402
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 7 Apr 2023 17:00:13 -0700
cleanup
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -13,7 +13,7 @@ use clap::Parser;
use clipboard::ClipboardContext;
use clipboard::ClipboardProvider;
use colors_transform::{Color, Rgb};
-use crossbeam_channel::{self, after, select};
+use crossbeam_channel::{self, after, RecvError, select};
use crossterm::event;
use crossterm::event::Event as CEvent;
use crossterm::event::{MouseEvent, MouseEventKind};
@@ -321,13 +321,17 @@ impl LeChatPHPClient {
let session = self.session.clone().unwrap();
let url = format!("{}?action=post&session={}", &full_url, &session);
thread::spawn(move || loop {
+ // select! macro fucks all the LSP, therefore the code gymnastic here
+ let clb = |v: Result<PostType, RecvError>| {
+ match v {
+ Ok(post_type_recv) => post_msg(&client, post_type_recv, &full_url, session.clone(), &url, &last_post_tx),
+ Err(_) => return,
+ }
+ };
let rx = rx.lock().unwrap();
select! {
recv(&exit_rx) -> _ => return,
- recv(&rx) -> v => match v {
- Ok(post_type_recv) => post_msg(&client, post_type_recv, &full_url, session.clone(), &url, &last_post_tx),
- Err(_) => return,
- },
+ recv(&rx) -> v => clb(v),
}
})
}