Merge Wholphin v1.1.0 while preserving Wolfskin features #27

Merged
justinzeus merged 72 commits from fm/wolfskin-upstream-1-1-0 into main 2026-11-05 01:49:35 +01:00
Showing only changes of commit 55960c2462 - Show all commits

View file

@ -89,6 +89,7 @@ import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.jellyfin.sdk.api.client.ApiClient
import org.jellyfin.sdk.api.client.extensions.libraryApi
import org.jellyfin.sdk.api.client.extensions.userLibraryApi
import org.jellyfin.sdk.model.api.BaseItemKind
import org.jellyfin.sdk.model.api.CollectionType
@ -168,15 +169,25 @@ class CollectionFolderViewModel
val id = collectionFilter.libraryDisplayInfoIdOverride ?: itemId
libraryDisplayInfoDao.getItem(user, id)
}
val ancestorDisplayInfo =
if (libraryDisplayInfo?.viewOptions == null && item != null) {
getAncestorDisplayInfo(item)
} else {
null
}
_state.update {
it.copy(
viewOptions = libraryDisplayInfo?.viewOptions ?: defaultViewOptions,
viewOptions =
libraryDisplayInfo?.viewOptions
?: ancestorDisplayInfo?.viewOptions
?: defaultViewOptions,
)
}
val sortAndDirection =
if (collectionFilter.useSavedLibraryDisplayInfo) {
libraryDisplayInfo?.sortAndDirection
?: ancestorDisplayInfo?.sortAndDirection
} else {
null
} ?: initialSortAndDirection ?: SortAndDirection.DEFAULT
@ -232,6 +243,25 @@ class CollectionFolderViewModel
}
}
/**
* For a sub-folder, returns the saved display info of the closest ancestor that has one
*/
private suspend fun getAncestorDisplayInfo(item: BaseItem): LibraryDisplayInfo? {
if (item.type != BaseItemKind.FOLDER || collectionFilter.libraryDisplayInfoIdOverride != null) {
return null
}
val user = serverRepository.currentUser ?: return null
return try {
api.libraryApi
.getAncestors(item.id, user.id)
.content
.firstNotNullOfOrNull { ancestor -> libraryDisplayInfoDao.getItem(user, ancestor.id) }
} catch (ex: Exception) {
Timber.w(ex, "Error getting ancestors for %s", item.id)
null
}
}
private fun saveLibraryDisplayInfo(
newFilter: GetItemsFilter = state.value.filter,
newSort: SortAndDirection = state.value.sortAndDirection,