Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove local playlists when removing S2 Media Provider #114

Merged

Conversation

daladim
Copy link
Contributor

@daladim daladim commented Feb 24, 2023

Closes #113

With this PR, removing a local provider not only removes the associated songs, but also the associated playlists.

@daladim
Copy link
Contributor Author

daladim commented Feb 24, 2023

However, an already existing issue is now turned into a bug. I am not knowledgeable in Kotlin/Android (yet?) to be able to fix it.

When the local provider is removed, and we browse back to the playlist view, all playlists have disappeared except for several "Favourites" playlists.
It is expected that one default, empty "Favourites" playlist gets re-generated. But the more you do the "add a local provider, check the imported playlists, remove the local provider, check the displayed playlists" cycle, the more Favourites playlists get added.
I currently have 5 "Favourites" playlists.

Some investigation:

  • Removing the local provider correctly removes every playlist from the room DB (even the multiple Favourites playlists).
  • When browsing to the Playlists screen, PlaybackPresenter::updateFavorite() is called n times. I don't get why n equals to the number of "cycles" I have done (n=1 at first, but it is currently 5 for me because I've made the test 5 times).
  • Each of it calls one playlistRepository.getFavoritesPlaylist()
  • Because there is no such "Favourites" playlists (the database has just been cleared), this creates one (by calling createPlaylist(name = favoritesName, ...). This is expected
  • However, for some reason (async coroutines I guess? The stack trace stems from some AwakeSuspendedCoroutine, or whatever the exact name), the other n invocations of PlaybackPresenter::updateFavorite() do not see this freshly added "Favourites" playlist and each one created an extra "Favourites" playlist. At least, that's what the Timber.v(...) I have added show me (I am printing the count of playlists in the playlistRelay which is always 0).
  • Note: getFavoritesPlaylist() uses a playlistsRelay. As far I can tell, that's a kind of cache that could be out-of-sync (?). But the bug is the same, even when I replace this relay by a plain playlistDataDao.getAll()

Copy link
Owner

@timusus timusus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@timusus
Copy link
Owner

timusus commented Mar 10, 2023

I'll dig around and see if I can figure out what's going on with the favourites playlist

@timusus timusus merged commit 6e9d6d0 into timusus:main Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Removing the S2 Media Providers does not remove playlists
2 participants