dupontgu / retro-ipod-spotify-client

The software that powers the sPot: a 4th generation "Click Wheel" iPod with a full Spotify client.
Apache License 2.0
928 stars 94 forks source link

Fix Playlist order from Spotify Library not being used #26

Closed 3urobeat closed 3 years ago

3urobeat commented 3 years ago

Hey!
This commit fixes the Playlist list not appearing in the same order as in your Spotify Library.

How: I did this by adding a new idx parameter to the UserPlaylist class.
This parameter is getting fed by a totalindex variable that counts all iterations of the first and the second (offset) loop which fetch the users playlist data in frontend/spotify_manager.py.
The init function of the PlaylistPage class in view_model.py then sorts the playlists list by getting the idx of each playlist from the UserPlaylist class using the added get_idx() function.

When fetching all playlists using spotipy in refresh_data() the order of supplied playlists was always the same as in the users Spotify library. But this order wasn't kept in the list and therefore also not in the Playlists menu.

Note: Deleting pycache and calling refresh_data() once is necessary.

~~Another note:
This pull request does not include my changes from my other pull request so if that should get accepted do I then need to add those changes to this branch too? Otherwise they would get reset by this pull request or am I wrong? That would be no problem to do but I just want to ask before doing something stupid and combining these two pull requests together didn't seem logical for me as they address different issues.
Sorry, I haven't worked with pull requests that much.~~ Edit: Doesn't make sense - the point of pull requests is to update parts of the code and not to replace a whole file.