Skip to content

Commit

Permalink
Fix clippy warnings after Rust upgrade (Rigellute#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigellute authored Aug 23, 2021
1 parent 6a999d8 commit 5884dd6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 58 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ secrets.tar

*.swp
tags

.idea
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ impl App {
}

if let Some(saved_artists) = &self.library.saved_artists.get_results(None).cloned() {
self.set_saved_artists_to_table(&saved_artists);
self.set_saved_artists_to_table(saved_artists);
}
}

Expand Down Expand Up @@ -810,7 +810,7 @@ impl App {
}

if let Some(saved_tracks) = &self.library.saved_tracks.get_results(None).cloned() {
self.set_saved_tracks_to_table(&saved_tracks);
self.set_saved_tracks_to_table(saved_tracks);
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/handlers/search_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,9 @@ fn handle_recommended_tracks(app: &mut App) {
if let Some(index) = &app.search_results.selected_tracks_index {
if let Some(result) = app.search_results.tracks.clone() {
if let Some(track) = result.items.get(index.to_owned()) {
let track_id_list: Option<Vec<String>> = match &track.id {
Some(id) => Some(vec![id.to_string()]),
None => None,
};
let track_id_list: Option<Vec<String>> =
track.id.as_ref().map(|id| vec![id.to_string()]);

app.recommendations_context = Some(RecommendationsContext::Song);
app.recommendations_seed = track.name.clone();
app.get_recommendations_for_seed(None, track_id_list, Some(track.clone()));
Expand Down
32 changes: 10 additions & 22 deletions src/handlers/track_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,8 @@ fn handle_recommended_tracks(app: &mut App) {
let (selected_index, tracks) = (&app.track_table.selected_index, &app.track_table.tracks);
if let Some(track) = tracks.get(*selected_index) {
let first_track = track.clone();
let track_id_list: Option<Vec<String>> = match &track.id {
Some(id) => Some(vec![id.to_string()]),
None => None,
};
let track_id_list = track.id.as_ref().map(|id| vec![id.to_string()]);

app.recommendations_context = Some(RecommendationsContext::Song);
app.recommendations_seed = first_track.name.clone();
app.get_recommendations_for_seed(None, track_id_list, Some(first_track));
Expand Down Expand Up @@ -321,14 +319,10 @@ fn on_enter(app: &mut App) {
TrackTableContext::MyPlaylists => {
if let Some(_track) = tracks.get(*selected_index) {
let context_uri = match (&app.active_playlist_index, &app.playlists) {
(Some(active_playlist_index), Some(playlists)) => {
if let Some(selected_playlist) = playlists.items.get(active_playlist_index.to_owned())
{
Some(selected_playlist.uri.to_owned())
} else {
None
}
}
(Some(active_playlist_index), Some(playlists)) => playlists
.items
.get(active_playlist_index.to_owned())
.map(|selected_playlist| selected_playlist.uri.to_owned()),
_ => None,
};

Expand Down Expand Up @@ -379,16 +373,10 @@ fn on_enter(app: &mut App) {
&app.search_results.selected_playlists_index,
&app.search_results.playlists,
) {
(Some(selected_playlist_index), Some(playlist_result)) => {
if let Some(selected_playlist) = playlist_result
.items
.get(selected_playlist_index.to_owned())
{
Some(selected_playlist.uri.to_owned())
} else {
None
}
}
(Some(selected_playlist_index), Some(playlist_result)) => playlist_result
.items
.get(selected_playlist_index.to_owned())
.map(|selected_playlist| selected_playlist.uri.to_owned()),
_ => None,
};

Expand Down
5 changes: 1 addition & 4 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,10 +1035,7 @@ impl<'a> Network<'a> {

async fn get_recommendations_for_track_id(&mut self, id: String, country: Option<Country>) {
if let Ok(track) = self.spotify.track(&id).await {
let track_id_list: Option<Vec<String>> = match &track.id {
Some(id) => Some(vec![id.to_string()]),
None => None,
};
let track_id_list = track.id.as_ref().map(|id| vec![id.to_string()]);
self
.get_recommendations_for_seed(None, track_id_list, Box::new(Some(track)), country)
.await;
Expand Down
54 changes: 28 additions & 26 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,32 +680,34 @@ where
);

let album_ui = match &app.album_table_context {
AlbumTableContext::Simplified => match &app.selected_album_simplified {
Some(selected_album_simplified) => Some(AlbumUi {
items: selected_album_simplified
.tracks
.items
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
format: vec![
"".to_string(),
item.track_number.to_string(),
item.name.to_owned(),
create_artist_string(&item.artists),
millis_to_minutes(u128::from(item.duration_ms)),
],
})
.collect::<Vec<TableItem>>(),
title: format!(
"{} by {}",
selected_album_simplified.album.name,
create_artist_string(&selected_album_simplified.album.artists)
),
selected_index: selected_album_simplified.selected_index,
}),
None => None,
},
AlbumTableContext::Simplified => {
app
.selected_album_simplified
.as_ref()
.map(|selected_album_simplified| AlbumUi {
items: selected_album_simplified
.tracks
.items
.iter()
.map(|item| TableItem {
id: item.id.clone().unwrap_or_else(|| "".to_string()),
format: vec![
"".to_string(),
item.track_number.to_string(),
item.name.to_owned(),
create_artist_string(&item.artists),
millis_to_minutes(u128::from(item.duration_ms)),
],
})
.collect::<Vec<TableItem>>(),
title: format!(
"{} by {}",
selected_album_simplified.album.name,
create_artist_string(&selected_album_simplified.album.artists)
),
selected_index: selected_album_simplified.selected_index,
})
}
AlbumTableContext::Full => match app.selected_album_full.clone() {
Some(selected_album) => Some(AlbumUi {
items: selected_album
Expand Down

0 comments on commit 5884dd6

Please sign in to comment.