mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Fix crash when adding to playlist while instance down
This commit is contained in:
parent
5b2d502f89
commit
ed67d09779
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user