{{ message }}
Repository navigation
Stop queueing the same episode twice in MockEpisodePlayer - #1731
Open
rootkiller6788 wants to merge 2 commits into
Open
rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
play(listOf(...)) rebuilt the queue inside a map() over the new episodes and used a captured var to remember the leftovers, so the leftover list was overwritten once per episode: only the removals for the very last episode of the new list survived. Episodes that were both in the new list and in the queue ended up in the queue twice. The currently playing episode was also appended unconditionally. The callers (LatestEpisodeViewModel/PodcastDetailsViewModel/QueueViewModel) set currentEpisode to the first episode of the list right before calling play(list), so that episode was queued a second time and played again at the end of the queue. Build the leftover list once with filterNot and skip the playing episode when the new list already contains it.
Both cases come from the Wear app: playing a whole episode list twice in a row used to leave the first episode in the queue again, and an episode that was already queued showed up twice after being re-queued.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Playing a whole episode list (podcast details, latest episodes, queue screens on Wear) was leaving the same episode in the queue twice, so it came back around and played again at the end.
Two problems in MockEpisodePlayer.play(list):
I now compute the leftovers once with filterNot, and only add the playing episode back when the new list does not contain it. Two tests cover both cases - I ran them against the current code first and they fail with the duplicate entry, then pass with the change. All 11 tests in MockEpisodePlayerTest are green.
Note: I have no Android SDK on this machine, so I could not run the full Jetcaster build. I compiled MockEpisodePlayer and its test with a plain Kotlin/JVM setup (kotlinc 2.2.20 + kotlinx-coroutines-test) instead.