Played/Unplayed status for "Collection" and "TV Shows" (#1495)

* off recursive

* pr feedback

* Cleanup

Instantiate the collectionType in the `if let` since failure to cast `as? BaseItemDto` should count as false as well. Only set `parameters.isRecursive` once in if/else opposed to if -> override.

* wip

* fix recursive and item kinds

* rename, fix folders

---------

Co-authored-by: Quang <quang.ha@a2:3c:68:56:26:8d.home>
Co-authored-by: Joe <jpkribs@outlook.com>
Co-authored-by: Ethan Pippin <ethanpippin2343@gmail.com>
Co-authored-by: Quang <quang.ha@QrM3P.local>
This commit is contained in:
Quang 2025-06-03 17:42:11 -04:00 committed by GitHub
parent a1cbc2a132
commit c1563e52d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 50 additions and 8 deletions

View File

@ -0,0 +1,41 @@
//
// Swiftfin is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors
//
import JellyfinAPI
extension BaseItemDto: LibraryParent {
var libraryType: BaseItemKind? {
type
}
var supportedItemTypes: [BaseItemKind] {
guard let collectionType else { return [] }
switch (collectionType, libraryType) {
case (_, .folder):
return BaseItemKind.supportedCases
.appending([.folder, .collectionFolder])
case (.movies, _):
return [.movie]
case (.tvshows, _):
return [.series]
case (.boxsets, _):
return BaseItemKind.supportedCases
default:
return BaseItemKind.supportedCases
}
}
var isRecursiveCollection: Bool {
if let collectionType, [CollectionType.tvshows, CollectionType.boxsets].contains(collectionType) {
return false
}
return true
}
}

View File

@ -21,13 +21,6 @@ extension BaseItemDto: Displayable {
} }
} }
extension BaseItemDto: LibraryParent {
var libraryType: BaseItemKind? {
type
}
}
extension BaseItemDto: LibraryIdentifiable { extension BaseItemDto: LibraryIdentifiable {
var unwrappedIDHashOrZero: Int { var unwrappedIDHashOrZero: Int {

View File

@ -57,11 +57,13 @@ final class ItemLibraryViewModel: PagingLibraryViewModel<BaseItemDto> {
// Default values, expected to be overridden // Default values, expected to be overridden
// by parent or filters // by parent or filters
parameters.isRecursive = true
parameters.includeItemTypes = BaseItemKind.supportedCases parameters.includeItemTypes = BaseItemKind.supportedCases
parameters.sortOrder = [.ascending] parameters.sortOrder = [.ascending]
parameters.sortBy = [ItemSortBy.name.rawValue] parameters.sortBy = [ItemSortBy.name.rawValue]
/// Recursive should only apply to parents/folders and not to baseItems
parameters.isRecursive = (parent as? BaseItemDto)?.isRecursiveCollection ?? false
// Parent // Parent
if let parent { if let parent {
parameters = parent.setParentParameters(parameters) parameters = parent.setParentParameters(parameters)

View File

@ -757,6 +757,8 @@
E14EDEC92B8FB65F000F00A4 /* ItemFilterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDEC72B8FB65F000F00A4 /* ItemFilterType.swift */; }; E14EDEC92B8FB65F000F00A4 /* ItemFilterType.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDEC72B8FB65F000F00A4 /* ItemFilterType.swift */; };
E14EDECC2B8FB709000F00A4 /* ItemYear.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDECB2B8FB709000F00A4 /* ItemYear.swift */; }; E14EDECC2B8FB709000F00A4 /* ItemYear.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDECB2B8FB709000F00A4 /* ItemYear.swift */; };
E14EDECD2B8FB709000F00A4 /* ItemYear.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDECB2B8FB709000F00A4 /* ItemYear.swift */; }; E14EDECD2B8FB709000F00A4 /* ItemYear.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14EDECB2B8FB709000F00A4 /* ItemYear.swift */; };
E14FC7F42DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14FC7F32DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift */; };
E14FC7F52DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E14FC7F32DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift */; };
E150C0BA2BFD44F500944FFA /* ImagePipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = E150C0B92BFD44F500944FFA /* ImagePipeline.swift */; }; E150C0BA2BFD44F500944FFA /* ImagePipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = E150C0B92BFD44F500944FFA /* ImagePipeline.swift */; };
E150C0BB2BFD44F500944FFA /* ImagePipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = E150C0B92BFD44F500944FFA /* ImagePipeline.swift */; }; E150C0BB2BFD44F500944FFA /* ImagePipeline.swift in Sources */ = {isa = PBXBuildFile; fileRef = E150C0B92BFD44F500944FFA /* ImagePipeline.swift */; };
E150C0C12BFD62FD00944FFA /* JellyfinAPI in Frameworks */ = {isa = PBXBuildFile; productRef = E150C0C02BFD62FD00944FFA /* JellyfinAPI */; }; E150C0C12BFD62FD00944FFA /* JellyfinAPI in Frameworks */ = {isa = PBXBuildFile; productRef = E150C0C02BFD62FD00944FFA /* JellyfinAPI */; };
@ -1834,6 +1836,7 @@
E14EDEC42B8FB64E000F00A4 /* AnyItemFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyItemFilter.swift; sourceTree = "<group>"; }; E14EDEC42B8FB64E000F00A4 /* AnyItemFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyItemFilter.swift; sourceTree = "<group>"; };
E14EDEC72B8FB65F000F00A4 /* ItemFilterType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemFilterType.swift; sourceTree = "<group>"; }; E14EDEC72B8FB65F000F00A4 /* ItemFilterType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemFilterType.swift; sourceTree = "<group>"; };
E14EDECB2B8FB709000F00A4 /* ItemYear.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemYear.swift; sourceTree = "<group>"; }; E14EDECB2B8FB709000F00A4 /* ItemYear.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemYear.swift; sourceTree = "<group>"; };
E14FC7F32DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseItemDto+LibraryParent.swift"; sourceTree = "<group>"; };
E150C0B92BFD44F500944FFA /* ImagePipeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePipeline.swift; sourceTree = "<group>"; }; E150C0B92BFD44F500944FFA /* ImagePipeline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImagePipeline.swift; sourceTree = "<group>"; };
E152107B2947ACA000375CC2 /* InvertedLightAppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvertedLightAppIcon.swift; sourceTree = "<group>"; }; E152107B2947ACA000375CC2 /* InvertedLightAppIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InvertedLightAppIcon.swift; sourceTree = "<group>"; };
E1546776289AF46E00087E35 /* CollectionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionItemView.swift; sourceTree = "<group>"; }; E1546776289AF46E00087E35 /* CollectionItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionItemView.swift; sourceTree = "<group>"; };
@ -5227,6 +5230,7 @@
children = ( children = (
E1AD104C26D96CE3003E4A08 /* BaseItemDto.swift */, E1AD104C26D96CE3003E4A08 /* BaseItemDto.swift */,
E1937A3A288E54AD00CB80AA /* BaseItemDto+Images.swift */, E1937A3A288E54AD00CB80AA /* BaseItemDto+Images.swift */,
E14FC7F32DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift */,
E18845F426DD631E00B0C5B7 /* BaseItemDto+Poster.swift */, E18845F426DD631E00B0C5B7 /* BaseItemDto+Poster.swift */,
E18A8E7C28D606BE00333B9A /* BaseItemDto+VideoPlayerViewModel.swift */, E18A8E7C28D606BE00333B9A /* BaseItemDto+VideoPlayerViewModel.swift */,
); );
@ -5947,6 +5951,7 @@
E102314B2BCF8A6D009D71FC /* ProgramsViewModel.swift in Sources */, E102314B2BCF8A6D009D71FC /* ProgramsViewModel.swift in Sources */,
E1DD55382B6EE533007501C0 /* Task.swift in Sources */, E1DD55382B6EE533007501C0 /* Task.swift in Sources */,
4E2CE3942DA432C00004736A /* LogLevel.swift in Sources */, 4E2CE3942DA432C00004736A /* LogLevel.swift in Sources */,
E14FC7F52DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift in Sources */,
E1575EA1293E7B1E001665B1 /* String.swift in Sources */, E1575EA1293E7B1E001665B1 /* String.swift in Sources */,
4E699BC02CB3477D007CBD5D /* HomeSection.swift in Sources */, 4E699BC02CB3477D007CBD5D /* HomeSection.swift in Sources */,
E1E6C45429B1304E0064123F /* ChaptersActionButton.swift in Sources */, E1E6C45429B1304E0064123F /* ChaptersActionButton.swift in Sources */,
@ -6811,6 +6816,7 @@
E1ED7FDC2CAA4B6D00ACB6E3 /* PlayerStateInfo.swift in Sources */, E1ED7FDC2CAA4B6D00ACB6E3 /* PlayerStateInfo.swift in Sources */,
E149CCAD2BE6ECC8008B9331 /* Storable.swift in Sources */, E149CCAD2BE6ECC8008B9331 /* Storable.swift in Sources */,
E1CB75792C80ECF100217C76 /* VideoPlayerType+Native.swift in Sources */, E1CB75792C80ECF100217C76 /* VideoPlayerType+Native.swift in Sources */,
E14FC7F42DB4436A005F0FB0 /* BaseItemDto+LibraryParent.swift in Sources */,
E1401CA72938140300E8B599 /* PrimaryAppIcon.swift in Sources */, E1401CA72938140300E8B599 /* PrimaryAppIcon.swift in Sources */,
E1937A3E288F0D3D00CB80AA /* UIScreen.swift in Sources */, E1937A3E288F0D3D00CB80AA /* UIScreen.swift in Sources */,
E10B1EBE2BD9AD5C00A92EAF /* V1ServerModel.swift in Sources */, E10B1EBE2BD9AD5C00A92EAF /* V1ServerModel.swift in Sources */,