Sort items alphabetical on name

This commit is contained in:
Jarne Demeulemeester 2021-10-12 20:41:08 +02:00
parent 07d9ae676c
commit c7a816ff6f
No known key found for this signature in database
GPG key ID: B61B7B150DB6A6D2
2 changed files with 10 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package dev.jdtech.jellyfin.repository
import org.jellyfin.sdk.model.api.BaseItemDto
import org.jellyfin.sdk.model.api.ItemFields
import org.jellyfin.sdk.model.api.MediaSourceInfo
import org.jellyfin.sdk.model.api.SortOrder
import java.util.*
interface JellyfinRepository {
@ -13,7 +14,9 @@ interface JellyfinRepository {
suspend fun getItems(
parentId: UUID? = null,
includeTypes: List<String>? = null,
recursive: Boolean = false
recursive: Boolean = false,
sortBy: String = "SortName",
sortOrder: SortOrder = SortOrder.ASCENDING
): List<BaseItemDto>
suspend fun getFavoriteItems(): List<BaseItemDto>

View file

@ -28,7 +28,9 @@ class JellyfinRepositoryImpl(private val jellyfinApi: JellyfinApi) : JellyfinRep
override suspend fun getItems(
parentId: UUID?,
includeTypes: List<String>?,
recursive: Boolean
recursive: Boolean,
sortBy: String,
sortOrder: SortOrder
): List<BaseItemDto> {
val items: List<BaseItemDto>
withContext(Dispatchers.IO) {
@ -36,7 +38,9 @@ class JellyfinRepositoryImpl(private val jellyfinApi: JellyfinApi) : JellyfinRep
jellyfinApi.userId!!,
parentId = parentId,
includeItemTypes = includeTypes,
recursive = recursive
recursive = recursive,
sortBy = listOf(sortBy),
sortOrder = listOf(sortOrder)
).content.items ?: listOf()
}
return items