Skip to content

Commit

Permalink
Fix use of incorrect playlist index when playing from an associated t…
Browse files Browse the repository at this point in the history
…rack table (Rigellute#632)
  • Loading branch information
Utagai authored Oct 27, 2020
1 parent 4382a32 commit 9500654
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ pub struct App {
pub selected_album_full: Option<SelectedFullAlbum>,
pub selected_device_index: Option<usize>,
pub selected_playlist_index: Option<usize>,
pub active_playlist_index: Option<usize>,
pub size: Rect,
pub small_search_limit: u32,
pub song_progress_ms: u128,
Expand Down Expand Up @@ -368,6 +369,7 @@ impl Default for App {
song_progress_ms: 0,
selected_device_index: None,
selected_playlist_index: None,
active_playlist_index: None,
track_table: Default::default(),
episode_table: Default::default(),
user: None,
Expand Down
1 change: 1 addition & 0 deletions src/handlers/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub fn handler(key: Key, app: &mut App) {
if let (Some(playlists), Some(selected_playlist_index)) =
(&app.playlists, &app.selected_playlist_index)
{
app.active_playlist_index = Some(selected_playlist_index.to_owned());
app.track_table.context = Some(TrackTableContext::MyPlaylists);
app.playlist_offset = 0;
if let Some(selected_playlist) = playlists.items.get(selected_playlist_index.to_owned()) {
Expand Down
7 changes: 3 additions & 4 deletions src/handlers/track_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,9 @@ fn on_enter(app: &mut App) {
Some(context) => match context {
TrackTableContext::MyPlaylists => {
if let Some(_track) = tracks.get(*selected_index) {
let context_uri = match (&app.selected_playlist_index, &app.playlists) {
(Some(selected_playlist_index), Some(playlists)) => {
if let Some(selected_playlist) =
playlists.items.get(selected_playlist_index.to_owned())
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 {
Expand Down

0 comments on commit 9500654

Please sign in to comment.