Merge pull request #3519 from Bnyro/master

Fix crash when adding to playlist while instance down
This commit is contained in:
Bnyro 2023-04-10 13:39:05 +02:00 committed by GitHub
commit f492f6dd6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,13 +80,16 @@ class AddToPlaylistDialog(
private suspend fun addToPlaylist(playlistId: String) {
val appContext = context?.applicationContext ?: return
val streams = when {
videoId != null -> listOf(
RetrofitInstance.api.getStreams(videoId).toStreamItem(videoId)
videoId != null -> listOfNotNull(
runCatching {
RetrofitInstance.api.getStreams(videoId!!).toStreamItem(videoId)
}.getOrNull()
)
else -> PlayingQueue.getStreams()
}
val success = try {
if (streams.isEmpty()) throw IllegalArgumentException()
PlaylistsHelper.addToPlaylist(playlistId, *streams.toTypedArray())
} catch (e: Exception) {
Log.e(TAG(), e.toString())