bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit 825a2cbff8728a3071a2b879f26e0f9d4e4d3402
parent 0fbfdb5b9a8da5cf07e1d4242b3e5b9475999205
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  7 Apr 2023 16:40:45 -0700

cleanup

Diffstat:
Msrc/main.rs | 22+++++++---------------
1 file changed, 7 insertions(+), 15 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, Select}; +use crossbeam_channel::{self, after, select}; use crossterm::event; use crossterm::event::Event as CEvent; use crossterm::event::{MouseEvent, MouseEventKind}; @@ -322,20 +322,12 @@ impl LeChatPHPClient { let url = format!("{}?action=post&session={}", &full_url, &session); thread::spawn(move || loop { let rx = rx.lock().unwrap(); - - let mut sel = Select::new(); - let oper1 = sel.recv(&rx); - let oper2 = sel.recv(&exit_rx); - let oper = sel.select(); - - if oper.index() == oper2 { - if oper.recv(&exit_rx).is_ok() { - return; - } - } else if oper.index() == oper1 { - if let Ok(post_type_recv) = oper.recv(&rx) { - post_msg(&client, post_type_recv, &full_url, session.clone(), &url, &last_post_tx); - } + 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, + }, } }) }