fix(player): Fix infinite loop in empty video lists (#1168)

Co-authored-by: Secozzi <49240133+Secozzi@users.noreply.github.com>
This commit is contained in:
Claudemirovsky 2023-10-22 17:58:56 -03:00 committed by GitHub
parent 418137c74e
commit c962b2894e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -248,7 +248,13 @@ class PlayerViewModel(
val currentEp = currentEpisode ?: throw Exception("No episode loaded.")
currentVideoList = EpisodeLoader.getLinks(currentEp.toDomainEpisode()!!, anime, source).asFlow().first()
EpisodeLoader.getLinks(currentEp.toDomainEpisode()!!, anime, source).asFlow().first()
.takeIf { it.isNotEmpty() }
?.also { currentVideoList = it }
?: run {
currentVideoList = null
throw Exception("Video list is empty.")
}
savedEpisodeId = currentEp.id!!
Pair(currentVideoList, Result.success(true))