Fix all 16 clippy warnings
- Collapse else { if } blocks into else if (6 instances)
- Replace map_or(false, ...) with is_some_and(...) (6 instances)
- Replace iter().cloned().collect() with .to_vec() (2 instances)
- Replace manual char comparison with array pattern (1 instance)
- Replace useless vec! with array literal (1 instance)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -157,8 +157,7 @@ impl App {
|
|||||||
|
|
||||||
if was_expanded {
|
if was_expanded {
|
||||||
state.artists.expanded.remove(&artist_id);
|
state.artists.expanded.remove(&artist_id);
|
||||||
} else {
|
} else if !state.artists.albums_cache.contains_key(&artist_id) {
|
||||||
if !state.artists.albums_cache.contains_key(&artist_id) {
|
|
||||||
drop(state);
|
drop(state);
|
||||||
if let Some(ref client) = self.subsonic {
|
if let Some(ref client) = self.subsonic {
|
||||||
match client.get_artist(&artist_id).await {
|
match client.get_artist(&artist_id).await {
|
||||||
@@ -180,7 +179,6 @@ impl App {
|
|||||||
state.artists.expanded.insert(artist_id);
|
state.artists.expanded.insert(artist_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
TreeItem::Album { album } => {
|
TreeItem::Album { album } => {
|
||||||
let album_id = album.id.clone();
|
let album_id = album.id.clone();
|
||||||
let album_name = album.name.clone();
|
let album_name = album.name.clone();
|
||||||
@@ -296,15 +294,13 @@ impl App {
|
|||||||
state.notify(format!("Added to queue: {}", title));
|
state.notify(format!("Added to queue: {}", title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if !state.artists.songs.is_empty() {
|
||||||
if !state.artists.songs.is_empty() {
|
|
||||||
let count = state.artists.songs.len();
|
let count = state.artists.songs.len();
|
||||||
let songs = state.artists.songs.clone();
|
let songs = state.artists.songs.clone();
|
||||||
state.queue.extend(songs);
|
state.queue.extend(songs);
|
||||||
state.notify(format!("Added {} songs to queue", count));
|
state.notify(format!("Added {} songs to queue", count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
KeyCode::Char('n') => {
|
KeyCode::Char('n') => {
|
||||||
let insert_pos = state.queue_position.map(|p| p + 1).unwrap_or(0);
|
let insert_pos = state.queue_position.map(|p| p + 1).unwrap_or(0);
|
||||||
if state.artists.focus == 1 {
|
if state.artists.focus == 1 {
|
||||||
@@ -315,17 +311,15 @@ impl App {
|
|||||||
state.notify(format!("Playing next: {}", title));
|
state.notify(format!("Playing next: {}", title));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if !state.artists.songs.is_empty() {
|
||||||
if !state.artists.songs.is_empty() {
|
|
||||||
let count = state.artists.songs.len();
|
let count = state.artists.songs.len();
|
||||||
let songs: Vec<_> = state.artists.songs.iter().cloned().collect();
|
let songs: Vec<_> = state.artists.songs.to_vec();
|
||||||
for (i, song) in songs.into_iter().enumerate() {
|
for (i, song) in songs.into_iter().enumerate() {
|
||||||
state.queue.insert(insert_pos + i, song);
|
state.queue.insert(insert_pos + i, song);
|
||||||
}
|
}
|
||||||
state.notify(format!("Playing {} songs next", count));
|
state.notify(format!("Playing {} songs next", count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ impl App {
|
|||||||
|
|
||||||
// Second click = activate (same as Enter)
|
// Second click = activate (same as Enter)
|
||||||
let is_second_click = was_selected
|
let is_second_click = was_selected
|
||||||
&& self.last_click.map_or(false, |(lx, ly, t)| {
|
&& self.last_click.is_some_and(|(lx, ly, t)| {
|
||||||
lx == x && ly == y && t.elapsed().as_millis() < 500
|
lx == x && ly == y && t.elapsed().as_millis() < 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,8 +157,7 @@ impl App {
|
|||||||
|
|
||||||
if was_expanded {
|
if was_expanded {
|
||||||
state.artists.expanded.remove(&artist_id);
|
state.artists.expanded.remove(&artist_id);
|
||||||
} else {
|
} else if !state.artists.albums_cache.contains_key(&artist_id) {
|
||||||
if !state.artists.albums_cache.contains_key(&artist_id) {
|
|
||||||
drop(state);
|
drop(state);
|
||||||
if let Some(ref client) = self.subsonic {
|
if let Some(ref client) = self.subsonic {
|
||||||
match client.get_artist(&artist_id).await {
|
match client.get_artist(&artist_id).await {
|
||||||
@@ -181,7 +180,6 @@ impl App {
|
|||||||
state.artists.expanded.insert(artist_id);
|
state.artists.expanded.insert(artist_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
TreeItem::Album { album } => {
|
TreeItem::Album { album } => {
|
||||||
let album_id = album.id.clone();
|
let album_id = album.id.clone();
|
||||||
let album_name = album.name.clone();
|
let album_name = album.name.clone();
|
||||||
@@ -266,7 +264,7 @@ impl App {
|
|||||||
state.artists.selected_song = Some(item_index);
|
state.artists.selected_song = Some(item_index);
|
||||||
|
|
||||||
let is_second_click = was_selected
|
let is_second_click = was_selected
|
||||||
&& self.last_click.map_or(false, |(lx, ly, t)| {
|
&& self.last_click.is_some_and(|(lx, ly, t)| {
|
||||||
lx == x && ly == y && t.elapsed().as_millis() < 500
|
lx == x && ly == y && t.elapsed().as_millis() < 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -322,7 +320,7 @@ impl App {
|
|||||||
state.queue_state.selected = Some(item_index);
|
state.queue_state.selected = Some(item_index);
|
||||||
|
|
||||||
let is_second_click = was_selected
|
let is_second_click = was_selected
|
||||||
&& self.last_click.map_or(false, |(_, ly, t)| {
|
&& self.last_click.is_some_and(|(_, ly, t)| {
|
||||||
ly == y && t.elapsed().as_millis() < 500
|
ly == y && t.elapsed().as_millis() < 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -359,7 +357,7 @@ impl App {
|
|||||||
state.playlists.selected_playlist = Some(item_index);
|
state.playlists.selected_playlist = Some(item_index);
|
||||||
|
|
||||||
let is_second_click = was_selected
|
let is_second_click = was_selected
|
||||||
&& self.last_click.map_or(false, |(lx, ly, t)| {
|
&& self.last_click.is_some_and(|(lx, ly, t)| {
|
||||||
lx == x && ly == y && t.elapsed().as_millis() < 500
|
lx == x && ly == y && t.elapsed().as_millis() < 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -401,7 +399,7 @@ impl App {
|
|||||||
state.playlists.selected_song = Some(item_index);
|
state.playlists.selected_song = Some(item_index);
|
||||||
|
|
||||||
let is_second_click = was_selected
|
let is_second_click = was_selected
|
||||||
&& self.last_click.map_or(false, |(lx, ly, t)| {
|
&& self.last_click.is_some_and(|(lx, ly, t)| {
|
||||||
lx == x && ly == y && t.elapsed().as_millis() < 500
|
lx == x && ly == y && t.elapsed().as_millis() < 500
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -432,14 +430,12 @@ impl App {
|
|||||||
state.artists.selected_index = Some(sel - 1);
|
state.artists.selected_index = Some(sel - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(sel) = state.artists.selected_song {
|
||||||
if let Some(sel) = state.artists.selected_song {
|
|
||||||
if sel > 0 {
|
if sel > 0 {
|
||||||
state.artists.selected_song = Some(sel - 1);
|
state.artists.selected_song = Some(sel - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Page::Queue => {
|
Page::Queue => {
|
||||||
if let Some(sel) = state.queue_state.selected {
|
if let Some(sel) = state.queue_state.selected {
|
||||||
if sel > 0 {
|
if sel > 0 {
|
||||||
@@ -456,14 +452,12 @@ impl App {
|
|||||||
state.playlists.selected_playlist = Some(sel - 1);
|
state.playlists.selected_playlist = Some(sel - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(sel) = state.playlists.selected_song {
|
||||||
if let Some(sel) = state.playlists.selected_song {
|
|
||||||
if sel > 0 {
|
if sel > 0 {
|
||||||
state.playlists.selected_song = Some(sel - 1);
|
state.playlists.selected_song = Some(sel - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -38,13 +38,11 @@ impl Widget for Header {
|
|||||||
let chunks = Layout::horizontal([Constraint::Min(40), Constraint::Length(30)]).split(area);
|
let chunks = Layout::horizontal([Constraint::Min(40), Constraint::Length(30)]).split(area);
|
||||||
|
|
||||||
// Page tabs
|
// Page tabs
|
||||||
let titles: Vec<Line> = vec![
|
let titles: Vec<Line> = [Page::Artists,
|
||||||
Page::Artists,
|
|
||||||
Page::Queue,
|
Page::Queue,
|
||||||
Page::Playlists,
|
Page::Playlists,
|
||||||
Page::Server,
|
Page::Server,
|
||||||
Page::Settings,
|
Page::Settings]
|
||||||
]
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p: &Page| Line::from(format!("{} {}", p.shortcut(), p.label())))
|
.map(|p: &Page| Line::from(format!("{} {}", p.shortcut(), p.label())))
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ pub fn build_tree_items(state: &AppState) -> Vec<TreeItem> {
|
|||||||
// If expanded, add albums sorted by year (oldest first)
|
// If expanded, add albums sorted by year (oldest first)
|
||||||
if is_expanded {
|
if is_expanded {
|
||||||
if let Some(albums) = artists.albums_cache.get(&artist.id) {
|
if let Some(albums) = artists.albums_cache.get(&artist.id) {
|
||||||
let mut sorted_albums: Vec<Album> = albums.iter().cloned().collect();
|
let mut sorted_albums: Vec<Album> = albums.to_vec();
|
||||||
sorted_albums.sort_by(|a, b| {
|
sorted_albums.sort_by(|a, b| {
|
||||||
// Albums with no year go last
|
// Albums with no year go last
|
||||||
match (a.year, b.year) {
|
match (a.year, b.year) {
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ pub fn load_themes() -> Vec<ThemeData> {
|
|||||||
.filter(|e| {
|
.filter(|e| {
|
||||||
e.path()
|
e.path()
|
||||||
.extension()
|
.extension()
|
||||||
.map_or(false, |ext| ext == "toml")
|
.is_some_and(|ext| ext == "toml")
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
entries.sort_by_key(|e| e.file_name());
|
entries.sort_by_key(|e| e.file_name());
|
||||||
@@ -248,7 +248,7 @@ pub fn load_themes() -> Vec<ThemeData> {
|
|||||||
|
|
||||||
/// Convert a filename stem like "tokyo-night" or "rose_pine" to "Tokyo Night" or "Rose Pine"
|
/// Convert a filename stem like "tokyo-night" or "rose_pine" to "Tokyo Night" or "Rose Pine"
|
||||||
fn titlecase_filename(s: &str) -> String {
|
fn titlecase_filename(s: &str) -> String {
|
||||||
s.split(|c: char| c == '-' || c == '_')
|
s.split(['-', '_'])
|
||||||
.filter(|w| !w.is_empty())
|
.filter(|w| !w.is_empty())
|
||||||
.map(|word| {
|
.map(|word| {
|
||||||
let mut chars = word.chars();
|
let mut chars = word.chars();
|
||||||
|
|||||||
Reference in New Issue
Block a user