From 80b1bd854796861147856536c7cc5cd979c5c1e1 Mon Sep 17 00:00:00 2001 From: Barnabas Balogh Date: Sat, 20 Jun 2026 19:49:35 +0000 Subject: [PATCH] fix(data): gracefully skip unsupported library types during refresh Previously, toLibrary() threw UnsupportedOperationException for library types the app does not surface (e.g. boxsets, music, photos, live TV), which aborted the entire home screen refresh. Now these unsupported types are logged and skipped, preventing a single unexpected view from leaving the user with an empty home screen. --- .../data/catalog/InMemoryAppContentRepository.kt | 4 ++-- .../data/converter/BaseItemDtoConverter.kt | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt b/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt index eb04ee84..f86f038e 100644 --- a/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt +++ b/data/src/main/java/hu/bbara/purefin/data/catalog/InMemoryAppContentRepository.kt @@ -280,8 +280,8 @@ class InMemoryAppContentRepository @Inject constructor( // library detail screen via loadLibraryContent, and on the // home rows by loadSuggestions / loadContinueWatching / // loadLatestLibraryContent. - librariesItem.map { dto -> - val library = dto.toLibrary(serverUrl()) + librariesItem.mapNotNull { dto -> + val library = dto.toLibrary(serverUrl()) ?: return@mapNotNull null val count = jellyfinApiClient.getLibraryItemCount(library.id) ?: library.size when (library.type) { LibraryKind.MOVIES -> library.copy(movies = emptyList(), size = count) diff --git a/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt b/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt index 2af465bb..42e6247d 100644 --- a/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt +++ b/data/src/main/java/hu/bbara/purefin/data/converter/BaseItemDtoConverter.kt @@ -11,12 +11,13 @@ import hu.bbara.purefin.model.Season import hu.bbara.purefin.model.Series import org.jellyfin.sdk.model.api.BaseItemDto import org.jellyfin.sdk.model.api.CollectionType +import timber.log.Timber import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Locale import java.util.concurrent.TimeUnit -fun BaseItemDto.toLibrary(serverUrl: String): Library { +fun BaseItemDto.toLibrary(serverUrl: String): Library? { return when (collectionType) { CollectionType.MOVIES -> Library( id = id, @@ -42,10 +43,20 @@ fun BaseItemDto.toLibrary(serverUrl: String): Library { size = childCount ?: 0, series = emptyList(), ) - else -> throw UnsupportedOperationException("Unsupported library type: $collectionType") + else -> { + // Jellyfin servers can return other top-level views (e.g. boxsets, + // music, photos, live TV) that this app does not surface on the + // home dashboard. Skip them so a single unsupported view does + // not abort the whole refresh and leave the user with an empty + // home screen. + Timber.tag(TAG).w("Skipping unsupported library type: $collectionType") + null + } } } +private const val TAG = "BaseItemDtoConverter" + fun BaseItemDto.toMovie(serverUrl: String): Movie { return Movie( id = id,