Add an option to switch between flatten/grouped library view
By default, a library shows its items in a flatten view. This patch further adds an option that allows users to show items grouped in their own folders as well.
This commit is contained in:
parent
f84d796536
commit
e760a586d7
|
@ -324,6 +324,8 @@ internal enum L10n {
|
||||||
internal static var settings: String { return L10n.tr("Localizable", "settings") }
|
internal static var settings: String { return L10n.tr("Localizable", "settings") }
|
||||||
/// Show Cast & Crew
|
/// Show Cast & Crew
|
||||||
internal static var showCastAndCrew: String { return L10n.tr("Localizable", "showCastAndCrew") }
|
internal static var showCastAndCrew: String { return L10n.tr("Localizable", "showCastAndCrew") }
|
||||||
|
/// Show Flatten Library View
|
||||||
|
internal static var showFlattenView: String { return L10n.tr("Localizable", "showFlattenView") }
|
||||||
/// Show Missing Episodes
|
/// Show Missing Episodes
|
||||||
internal static var showMissingEpisodes: String { return L10n.tr("Localizable", "showMissingEpisodes") }
|
internal static var showMissingEpisodes: String { return L10n.tr("Localizable", "showMissingEpisodes") }
|
||||||
/// Show Missing Seasons
|
/// Show Missing Seasons
|
||||||
|
|
|
@ -41,6 +41,7 @@ extension Defaults.Keys {
|
||||||
// Customize settings
|
// Customize settings
|
||||||
static let showPosterLabels = Key<Bool>("showPosterLabels", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
static let showPosterLabels = Key<Bool>("showPosterLabels", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
static let showCastAndCrew = Key<Bool>("showCastAndCrew", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
static let showCastAndCrew = Key<Bool>("showCastAndCrew", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
static let showFlattenView = Key<Bool>("showFlattenView", default: true, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
|
||||||
// Video player / overlay settings
|
// Video player / overlay settings
|
||||||
static let overlayType = Key<OverlayType>("overlayType", default: .normal, suite: SwiftfinStore.Defaults.generalSuite)
|
static let overlayType = Key<OverlayType>("overlayType", default: .normal, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import Combine
|
import Combine
|
||||||
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
import SwiftUICollection
|
import SwiftUICollection
|
||||||
|
@ -94,10 +95,16 @@ final class LibraryViewModel: ViewModel {
|
||||||
genreIDs = filters.withGenres.compactMap(\.id)
|
genreIDs = filters.withGenres.compactMap(\.id)
|
||||||
}
|
}
|
||||||
let sortBy = filters.sortBy.map(\.rawValue)
|
let sortBy = filters.sortBy.map(\.rawValue)
|
||||||
let queryRecursive = filters.filters.contains(.isFavorite) ||
|
let queryRecursive = Defaults[.showFlattenView] || filters.filters.contains(.isFavorite) ||
|
||||||
self.person != nil ||
|
self.person != nil ||
|
||||||
self.genre != nil ||
|
self.genre != nil ||
|
||||||
self.studio != nil
|
self.studio != nil
|
||||||
|
let includeItemTypes: [String]
|
||||||
|
if filters.filters.contains(.isFavorite) {
|
||||||
|
includeItemTypes = ["Movie", "Series", "Season", "Episode", "BoxSet"]
|
||||||
|
} else {
|
||||||
|
includeItemTypes = ["Movie", "Series", "BoxSet"] + (Defaults[.showFlattenView] ? [] : ["Folder"])
|
||||||
|
}
|
||||||
|
|
||||||
ItemsAPI.getItemsByUserId(userId: SessionManager.main.currentLogin.user.id, startIndex: currentPage * pageItemSize,
|
ItemsAPI.getItemsByUserId(userId: SessionManager.main.currentLogin.user.id, startIndex: currentPage * pageItemSize,
|
||||||
limit: pageItemSize,
|
limit: pageItemSize,
|
||||||
|
@ -114,9 +121,7 @@ final class LibraryViewModel: ViewModel {
|
||||||
.people,
|
.people,
|
||||||
.chapters,
|
.chapters,
|
||||||
],
|
],
|
||||||
includeItemTypes: filters.filters
|
includeItemTypes: includeItemTypes,
|
||||||
.contains(.isFavorite) ? ["Movie", "Series", "Season", "Episode", "BoxSet"] :
|
|
||||||
["Movie", "Series", "BoxSet", "Folder"],
|
|
||||||
filters: filters.filters,
|
filters: filters.filters,
|
||||||
sortBy: sortBy,
|
sortBy: sortBy,
|
||||||
tags: filters.tags,
|
tags: filters.tags,
|
||||||
|
|
|
@ -15,6 +15,8 @@ struct CustomizeViewsSettings: View {
|
||||||
var showPosterLabels
|
var showPosterLabels
|
||||||
@Default(.showCastAndCrew)
|
@Default(.showCastAndCrew)
|
||||||
var showCastAndCrew
|
var showCastAndCrew
|
||||||
|
@Default(.showFlattenView)
|
||||||
|
var showFlattenView
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
@ -24,6 +26,7 @@ struct CustomizeViewsSettings: View {
|
||||||
|
|
||||||
// TODO: Uncomment when cast and crew implemented in item views
|
// TODO: Uncomment when cast and crew implemented in item views
|
||||||
// Toggle(L10n.showCastAndCrew, isOn: $showCastAndCrew)
|
// Toggle(L10n.showCastAndCrew, isOn: $showCastAndCrew)
|
||||||
|
Toggle(L10n.showFlattenView, isOn: $showFlattenView)
|
||||||
|
|
||||||
} header: {
|
} header: {
|
||||||
L10n.customize.text
|
L10n.customize.text
|
||||||
|
|
|
@ -15,6 +15,8 @@ struct CustomizeViewsSettings: View {
|
||||||
var showPosterLabels
|
var showPosterLabels
|
||||||
@Default(.showCastAndCrew)
|
@Default(.showCastAndCrew)
|
||||||
var showCastAndCrew
|
var showCastAndCrew
|
||||||
|
@Default(.showFlattenView)
|
||||||
|
var showFlattenView
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
|
@ -22,6 +24,7 @@ struct CustomizeViewsSettings: View {
|
||||||
|
|
||||||
Toggle(L10n.showPosterLabels, isOn: $showPosterLabels)
|
Toggle(L10n.showPosterLabels, isOn: $showPosterLabels)
|
||||||
Toggle(L10n.showCastAndCrew, isOn: $showCastAndCrew)
|
Toggle(L10n.showCastAndCrew, isOn: $showCastAndCrew)
|
||||||
|
Toggle(L10n.showFlattenView, isOn: $showFlattenView)
|
||||||
|
|
||||||
} header: {
|
} header: {
|
||||||
L10n.customize.text
|
L10n.customize.text
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue