Start removing Outcome class in favor of Result

This commit is contained in:
vfsfitvnm
2022-07-01 18:22:53 +02:00
parent 6ccbf7759c
commit c4fea8835a
5 changed files with 155 additions and 157 deletions

View File

@@ -5,6 +5,7 @@ import it.vfsfitvnm.youtubemusic.YouTube
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
data class YouTubeRadio(
private val videoId: String? = null,
private val playlistId: String? = null,
@@ -23,11 +24,11 @@ data class YouTubeRadio(
params = parameters,
playlistSetVideoId = playlistSetVideoId,
continuation = nextContinuation
)
}.map { nextResult ->
mediaItems = nextResult.items?.map(YouTube.Item.Song::asMediaItem)
nextResult.continuation?.takeUnless { nextContinuation == nextResult.continuation }
}.recoverWith(nextContinuation).valueOrNull
)?.getOrNull()?.let { nextResult ->
mediaItems = nextResult.items?.map(YouTube.Item.Song::asMediaItem)
nextResult.continuation?.takeUnless { nextContinuation == nextResult.continuation }
}
}
return mediaItems ?: emptyList()
}