mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30: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) {
|
private suspend fun addToPlaylist(playlistId: String) {
|
||||||
val appContext = context?.applicationContext ?: return
|
val appContext = context?.applicationContext ?: return
|
||||||
val streams = when {
|
val streams = when {
|
||||||
videoId != null -> listOf(
|
videoId != null -> listOfNotNull(
|
||||||
RetrofitInstance.api.getStreams(videoId).toStreamItem(videoId)
|
runCatching {
|
||||||
|
RetrofitInstance.api.getStreams(videoId!!).toStreamItem(videoId)
|
||||||
|
}.getOrNull()
|
||||||
)
|
)
|
||||||
else -> PlayingQueue.getStreams()
|
else -> PlayingQueue.getStreams()
|
||||||
}
|
}
|
||||||
|
|
||||||
val success = try {
|
val success = try {
|
||||||
|
if (streams.isEmpty()) throw IllegalArgumentException()
|
||||||
PlaylistsHelper.addToPlaylist(playlistId, *streams.toTypedArray())
|
PlaylistsHelper.addToPlaylist(playlistId, *streams.toTypedArray())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e(TAG(), e.toString())
|
Log.e(TAG(), e.toString())
|
||||||
|
Loading…
Reference in New Issue
Block a user