Browse Source

#83: Fix invalid null handling for add to playlist

deploy-in-docker
Ryan Harg 3 years ago
parent
commit
1209a0a5dc
  1. 5
      app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt
  2. 1
      changes/changelog.d/83.bugfix

5
app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt

@ -82,7 +82,7 @@ class ManagementPlaylistsRepository(override val context: Context?) : @@ -82,7 +82,7 @@ class ManagementPlaylistsRepository(override val context: Context?) :
}
fun add(id: Int, tracks: List<Track>) {
context?.let {
if (context != null) {
val body = PlaylistAdd(tracks.map { it.id }, false)
val request = Fuel.post(mustNormalizeUrl("/api/v1/playlists/$id/add/")).apply {
@ -98,9 +98,10 @@ class ManagementPlaylistsRepository(override val context: Context?) : @@ -98,9 +98,10 @@ class ManagementPlaylistsRepository(override val context: Context?) :
.body(Gson().toJson(body))
.awaitByteArrayResponseResult()
}
}
} else {
throw IllegalStateException("Illegal state: context is null")
}
}
suspend fun remove(id: Int, track: Track, index: Int) {
context?.let {

1
changes/changelog.d/83.bugfix

@ -0,0 +1 @@ @@ -0,0 +1 @@
Fix application crash when adding song to playlist (#83)
Loading…
Cancel
Save