Fix use of incorrect playlist index when playing from an associated track table#632
Conversation
|
Ooo, I think I may get the Hacktoberfest shirt this year, since I think this is my 4th PR. 😄 @Rigellute It's worth noting that this PR highlights a fundamental weakness in the codebase that I think we've seen issues with already: index state (to some degree, we have lots of small little pieces of state under |
| if let (Some(playlists), Some(selected_playlist_index)) = | ||
| (&app.playlists, &app.selected_playlist_index) | ||
| { | ||
| app.active_playlist_index = Some(selected_playlist_index.to_owned()); |
There was a problem hiding this comment.
From my look through the codebase, there is no other way in which we enter into the TableContext::MyPlaylists context, so this is all that is necessary to track the "active" playlist.
|
I agree that there is way too much state packed into the For instance, see this commit where delegation for managing the There's still a bit of work to be done to get all the cases of this, but most of the results we care about should actually be pageable, so I think once this massive overhaul (or some version of it) gets through, we will have a lot fewer instances of this issue cropping up. |
|
Just saw your draft PR @sputnick1124! Thanks for that work, it will definitely improve the code a lot! I agree the pageable results overhaul is a great step. We need to keep going in this direction of encapsulating the state into dedicated objects, whether that be better paging abstractions or context introductions, etc. In fact, I'm a little jealous you got to work on that refactor, it looks like it was a satisfying experience 🙂. |
This closes #628.
We had a poor assumption here, that the selected playlist index was always guaranteed to be the playlist for which the loaded track table's context referred to. However, this is not always true. Take the following steps:
Step 5 will attempt to play a song on the selected playlist, which is the one you never activated, leading to an unexpected song being played back. Instead, we need a particular state for the activated playlist index, which this PR adds and uses instead. This avoids the problem described in the issue.