fix: resolve clippy warnings in iced client
This commit is contained in:
+19
-22
@@ -605,7 +605,7 @@ impl App {
|
|||||||
let _ = handle
|
let _ = handle
|
||||||
.with_connection(move |con| -> Result<(), String> {
|
.with_connection(move |con| -> Result<(), String> {
|
||||||
let state = con.get_state().map_err(|e| e.to_string())?;
|
let state = con.get_state().map_err(|e| e.to_string())?;
|
||||||
if state.clients.get(&state.own_client).is_some() {
|
if state.clients.contains_key(&state.own_client) {
|
||||||
let cmd = state.client_update()
|
let cmd = state.client_update()
|
||||||
.set_input_muted(muted);
|
.set_input_muted(muted);
|
||||||
cmd.send(con).map_err(|e| e.to_string())?;
|
cmd.send(con).map_err(|e| e.to_string())?;
|
||||||
@@ -629,7 +629,7 @@ impl App {
|
|||||||
let _ = handle
|
let _ = handle
|
||||||
.with_connection(move |con| -> Result<(), String> {
|
.with_connection(move |con| -> Result<(), String> {
|
||||||
let state = con.get_state().map_err(|e| e.to_string())?;
|
let state = con.get_state().map_err(|e| e.to_string())?;
|
||||||
if state.clients.get(&state.own_client).is_some() {
|
if state.clients.contains_key(&state.own_client) {
|
||||||
let cmd = state.client_update()
|
let cmd = state.client_update()
|
||||||
.set_output_muted(muted);
|
.set_output_muted(muted);
|
||||||
cmd.send(con).map_err(|e| e.to_string())?;
|
cmd.send(con).map_err(|e| e.to_string())?;
|
||||||
@@ -653,7 +653,7 @@ impl App {
|
|||||||
let _ = handle
|
let _ = handle
|
||||||
.with_connection(move |con| -> Result<(), String> {
|
.with_connection(move |con| -> Result<(), String> {
|
||||||
let state = con.get_state().map_err(|e| e.to_string())?;
|
let state = con.get_state().map_err(|e| e.to_string())?;
|
||||||
if state.clients.get(&state.own_client).is_some() {
|
if state.clients.contains_key(&state.own_client) {
|
||||||
let cmd = state.client_update()
|
let cmd = state.client_update()
|
||||||
.set_output_hardware_enabled(!muted);
|
.set_output_hardware_enabled(!muted);
|
||||||
cmd.send(con).map_err(|e| e.to_string())?;
|
cmd.send(con).map_err(|e| e.to_string())?;
|
||||||
@@ -677,7 +677,7 @@ impl App {
|
|||||||
let _ = handle
|
let _ = handle
|
||||||
.with_connection(move |con| -> Result<(), String> {
|
.with_connection(move |con| -> Result<(), String> {
|
||||||
let state = con.get_state().map_err(|e| e.to_string())?;
|
let state = con.get_state().map_err(|e| e.to_string())?;
|
||||||
if state.clients.get(&state.own_client).is_some() {
|
if state.clients.contains_key(&state.own_client) {
|
||||||
let cmd = if afk {
|
let cmd = if afk {
|
||||||
state.client_update()
|
state.client_update()
|
||||||
.set_input_muted(true)
|
.set_input_muted(true)
|
||||||
@@ -909,18 +909,20 @@ impl App {
|
|||||||
// Keyboard events for PTT
|
// Keyboard events for PTT
|
||||||
subs.push(iced::event::listen().map(|event| {
|
subs.push(iced::event::listen().map(|event| {
|
||||||
match event {
|
match event {
|
||||||
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed { ref key, .. }) => {
|
iced::Event::Keyboard(iced::keyboard::Event::KeyPressed {
|
||||||
if let iced::keyboard::Key::Character(c) = key {
|
key: iced::keyboard::Key::Character(c),
|
||||||
if c.as_str().to_lowercase() == "v" {
|
..
|
||||||
return Message::PttPressed;
|
}) => {
|
||||||
}
|
if c.as_str().to_lowercase() == "v" {
|
||||||
|
return Message::PttPressed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { ref key, .. }) => {
|
iced::Event::Keyboard(iced::keyboard::Event::KeyReleased {
|
||||||
if let iced::keyboard::Key::Character(c) = key {
|
key: iced::keyboard::Key::Character(c),
|
||||||
if c.as_str().to_lowercase() == "v" {
|
..
|
||||||
return Message::PttReleased;
|
}) => {
|
||||||
}
|
if c.as_str().to_lowercase() == "v" {
|
||||||
|
return Message::PttReleased;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -972,14 +974,9 @@ impl App {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
loop {
|
while let Ok(samples) = sample_rx.recv() {
|
||||||
match sample_rx.recv() {
|
if sender.send(Message::MicSamples(samples)).await.is_err() {
|
||||||
Ok(samples) => {
|
break;
|
||||||
if sender.send(Message::MicSamples(samples)).await.is_err() {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => break,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut mic_guard = mic.lock().await;
|
let mut mic_guard = mic.lock().await;
|
||||||
|
|||||||
@@ -88,16 +88,11 @@ pub fn start_transmission(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
loop {
|
while let Ok(samples) = sample_rx.recv() {
|
||||||
match sample_rx.recv() {
|
let mut nr = noise_reducer.lock().await;
|
||||||
Ok(samples) => {
|
let mut samples_copy = samples.clone();
|
||||||
let mut nr = noise_reducer.lock().await;
|
nr.process(&mut samples_copy);
|
||||||
let mut samples_copy = samples.clone();
|
enc.encode_and_send(&samples_copy, &audio_tx);
|
||||||
nr.process(&mut samples_copy);
|
|
||||||
enc.encode_and_send(&samples_copy, &audio_tx);
|
|
||||||
}
|
|
||||||
Err(_) => break,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut mic_guard = mic.lock().await;
|
let mut mic_guard = mic.lock().await;
|
||||||
|
|||||||
@@ -855,7 +855,7 @@ impl App {
|
|||||||
|
|
||||||
pub(crate) fn recent_bookmarks(&self, limit: usize) -> Vec<&BookmarkInfo> {
|
pub(crate) fn recent_bookmarks(&self, limit: usize) -> Vec<&BookmarkInfo> {
|
||||||
let mut bookmarks: Vec<&BookmarkInfo> = self.bookmarks.iter().collect();
|
let mut bookmarks: Vec<&BookmarkInfo> = self.bookmarks.iter().collect();
|
||||||
bookmarks.sort_by(|a, b| b.last_used_at.cmp(&a.last_used_at));
|
bookmarks.sort_by_key(|bookmark| std::cmp::Reverse(bookmark.last_used_at));
|
||||||
bookmarks
|
bookmarks
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|bookmark| bookmark.last_used_at.is_some())
|
.filter(|bookmark| bookmark.last_used_at.is_some())
|
||||||
|
|||||||
Reference in New Issue
Block a user