Skip to content

Commit

Permalink
Fix app crash due to unwrap (Rigellute#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rigellute authored Oct 11, 2020
1 parent 9e03d06 commit c01b92c
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions src/handlers/made_for_you.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,21 @@ pub fn handler(key: Key, app: &mut App) {
}
}
Key::Enter => {
let (playlists, selected_playlist_index) = (
&app
.library
.made_for_you_playlists
.get_results(Some(0))
.unwrap(),
if let (Some(playlists), selected_playlist_index) = (
&app.library.made_for_you_playlists.get_results(Some(0)),
&app.made_for_you_index,
);
app.track_table.context = Some(TrackTableContext::MadeForYou);
app.playlist_offset = 0;
if let Some(selected_playlist) = playlists.items.get(selected_playlist_index.to_owned()) {
app.made_for_you_offset = 0;
let playlist_id = selected_playlist.id.to_owned();
app.dispatch(IoEvent::GetMadeForYouPlaylistTracks(
playlist_id,
app.made_for_you_offset,
));
}
) {
app.track_table.context = Some(TrackTableContext::MadeForYou);
app.playlist_offset = 0;
if let Some(selected_playlist) = playlists.items.get(selected_playlist_index.to_owned()) {
app.made_for_you_offset = 0;
let playlist_id = selected_playlist.id.to_owned();
app.dispatch(IoEvent::GetMadeForYouPlaylistTracks(
playlist_id,
app.made_for_you_offset,
));
}
};
}
_ => {}
}
Expand Down

0 comments on commit c01b92c

Please sign in to comment.