Twelve: Allow playlists to have no childs/comment
diff --git a/app/src/main/java/org/lineageos/twelve/datasources/SubsonicDataSource.kt b/app/src/main/java/org/lineageos/twelve/datasources/SubsonicDataSource.kt
index 1ab93a5..34dae50 100644
--- a/app/src/main/java/org/lineageos/twelve/datasources/SubsonicDataSource.kt
+++ b/app/src/main/java/org/lineageos/twelve/datasources/SubsonicDataSource.kt
@@ -135,7 +135,7 @@
override fun playlist(playlistUri: Uri) = _playlistsChanged.mapLatest {
subsonicClient.getPlaylist(playlistUri.lastPathSegment!!.toInt()).toRequestStatus {
- toPlaylist().toMediaItem() to entry.map {
+ toPlaylist().toMediaItem() to entry.orEmpty().map {
it.toMediaItem()
} as List<Audio?>
}
@@ -147,7 +147,7 @@
subsonicClient.getPlaylists().toRequestStatus {
playlist.map { playlist ->
playlist.toMediaItem() to subsonicClient.getPlaylist(playlist.id).toRequestStatus {
- entry.any { child -> child.id == audioId }
+ entry.orEmpty().any { child -> child.id == audioId }
}.let { requestStatus ->
(requestStatus as? RequestStatus.Success)?.data ?: false
}
@@ -190,7 +190,7 @@
).toRequestStatus {
val audioId = audioUri.lastPathSegment!!
- val audioIndexes = entry.mapIndexedNotNull { index, child ->
+ val audioIndexes = entry.orEmpty().mapIndexedNotNull { index, child ->
index.takeIf { child.id == audioId }
}
diff --git a/app/src/main/java/org/lineageos/twelve/datasources/subsonic/models/PlaylistWithSongs.kt b/app/src/main/java/org/lineageos/twelve/datasources/subsonic/models/PlaylistWithSongs.kt
index 99c9298..77dec9a 100644
--- a/app/src/main/java/org/lineageos/twelve/datasources/subsonic/models/PlaylistWithSongs.kt
+++ b/app/src/main/java/org/lineageos/twelve/datasources/subsonic/models/PlaylistWithSongs.kt
@@ -14,7 +14,7 @@
val allowedUser: List<String>? = null,
val id: Int,
val name: String,
- val comment: String?,
+ val comment: String? = null,
val owner: String? = null,
val public: Boolean? = null,
val songCount: Int,
@@ -24,7 +24,7 @@
val coverArt: String? = null,
// Playlist end
- val entry: List<Child>,
+ val entry: List<Child>? = null,
) {
fun toPlaylist() = Playlist(
allowedUser = allowedUser,