diff --git a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt index daf119a..0dca88d 100644 --- a/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt +++ b/app/src/main/java/audio/funkwhale/ffa/repositories/PlaylistsRepository.kt @@ -108,7 +108,7 @@ class ManagementPlaylistsRepository(override val context: Context?) : } suspend fun remove(albumId: Int, index: Int) { - context?.let { + if (context != null) { val body = mapOf("index" to index) val request = Fuel.post(mustNormalizeUrl("/api/v1/playlists/$albumId/remove/")).apply { @@ -122,12 +122,13 @@ class ManagementPlaylistsRepository(override val context: Context?) : .header("Content-Type", "application/json") .body(Gson().toJson(body)) .awaitByteArrayResponseResult() - } - throw IllegalStateException("Illegal state: context is null") + } else { + throw IllegalStateException("Illegal state: context is null") + } } fun move(id: Int, from: Int, to: Int) { - context?.let { + if (context != null) { val body = mapOf("from" to from, "to" to to) val request = Fuel.post(mustNormalizeUrl("/api/v1/playlists/$id/move/")).apply { @@ -143,7 +144,8 @@ class ManagementPlaylistsRepository(override val context: Context?) : .body(Gson().toJson(body)) .awaitByteArrayResponseResult() } + } else { + throw IllegalStateException("Illegal state: context is null") } - throw IllegalStateException("Illegal state: context is null") } } diff --git a/changes/changelog.d/113.bugfix b/changes/changelog.d/113.bugfix new file mode 100644 index 0000000..db68433 --- /dev/null +++ b/changes/changelog.d/113.bugfix @@ -0,0 +1 @@ +Fix App crashes when interacting with playlist