Don't display production year when it is null
This commit is contained in:
parent
3f83d07636
commit
c8b6848e28
1 changed files with 16 additions and 12 deletions
|
@ -13,7 +13,6 @@ import dev.jdtech.jellyfin.repository.JellyfinRepository
|
||||||
import dev.jdtech.jellyfin.utils.*
|
import dev.jdtech.jellyfin.utils.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.jellyfin.sdk.api.client.exception.ApiClientException
|
import org.jellyfin.sdk.api.client.exception.ApiClientException
|
||||||
|
@ -244,18 +243,18 @@ constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDateString(item: BaseItemDto): String {
|
private fun getDateString(item: BaseItemDto): String {
|
||||||
val dateString: String = item.productionYear.toString()
|
val dateRange: MutableList<String> = mutableListOf()
|
||||||
return when (item.status) {
|
item.productionYear?.let { dateRange.add(it.toString()) }
|
||||||
"Continuing" -> dateString.plus(" - Present")
|
when (item.status) {
|
||||||
"Ended" -> {
|
"Continuing" -> {
|
||||||
return if (item.productionYear == item.endDate?.year) {
|
dateRange.add("Present")
|
||||||
dateString
|
}
|
||||||
} else {
|
"Ended" -> {
|
||||||
dateString.plus(" - ${item.endDate?.year}")
|
item.endDate?.let { dateRange.add(it.year.toString()) }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> dateString
|
|
||||||
}
|
}
|
||||||
|
if (dateRange.count() > 1 && dateRange[0] == dateRange[1]) return dateRange[0]
|
||||||
|
return dateRange.joinToString(separator = " - ")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadDownloadRequestItem(itemId: UUID) {
|
fun loadDownloadRequestItem(itemId: UUID) {
|
||||||
|
@ -266,7 +265,12 @@ constructor(
|
||||||
val metadata = baseItemDtoToDownloadMetadata(downloadItem)
|
val metadata = baseItemDtoToDownloadMetadata(downloadItem)
|
||||||
downloadRequestItem = DownloadRequestItem(uri, itemId, metadata)
|
downloadRequestItem = DownloadRequestItem(uri, itemId, metadata)
|
||||||
downloadMedia = true
|
downloadMedia = true
|
||||||
requestDownload(downloadDatabase, Uri.parse(downloadRequestItem.uri), downloadRequestItem, application)
|
requestDownload(
|
||||||
|
downloadDatabase,
|
||||||
|
Uri.parse(downloadRequestItem.uri),
|
||||||
|
downloadRequestItem,
|
||||||
|
application
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue