-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS & tvOS] ItemLibraryViewModel - Cleanup #1411
base: main
Are you sure you want to change the base?
Conversation
@LePips This all looks correct and is working as intended. Please let me know if there is anything that I should be doing differently or if you had any other cleanup intended! The only missing item I'd like to roll into this PR is from I was looking at adding this (see below) but might need a bit more context. Since
One unintended side effect of using the |
…gLibraryView` to have the default filters. This was originally in place. This Commit just ensures that iOS and tvOS have the same implementation.
@@ -102,7 +102,7 @@ struct PagingLibraryView<Element: Poster & Identifiable>: View { | |||
private func select(item: BaseItemDto) { | |||
switch item.type { | |||
case .collectionFolder, .folder: | |||
let viewModel = ItemLibraryViewModel(parent: item) | |||
let viewModel = ItemLibraryViewModel(parent: item, filters: .default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am adding this to mirror iOS.
@@ -117,6 +115,11 @@ final class ItemLibraryViewModel: PagingLibraryViewModel<BaseItemDto> { | |||
if filters.sortBy.first == ItemSortBy.random { | |||
parameters.excludeItemIDs = elements.compactMap(\.id) | |||
} | |||
} else { | |||
// Default item types & sort order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does 2 things:
-
Right now, when filters are not present, there is no sort order. For an example, take the current 1.2 or 1.3(5) version and open select a person. It will show you all of their movies & shows but in no specific order. This is because the order is set from the
FilterViewModel
. This ensure, if theFilterViewModel
is not present, this will default to ordering the results by name. -
Since I am using the
includeItemTypes
in theFilterViewModel
, I don't want to set this value twice, This[.movie, .series, .boxSet]
is the previously default value for this, so I am ensuring this is set when aFilterViewModel
is not present (see people again). This is the same default found on theFilterViewModel
so it will be set there as well if the view does not use these values.
The alternative to this is I can reference FilterViewModel.init().currentFilters.types
so this is only being set from the FilterViewModel
?
Summary
The goal of this. PR is to touch up the
ItemLibraryViewModel
to accommodate some of the new items that we've added since it was created. @LePips left some notes in in there andItemTypeLIbraryViewModel
and mostly I am going to try and follow them.Primary change was I removed
ItemTypeLIbraryViewModel
and movedItemType
to the theItemFilterCollection
instead. I've tested on tvOS and all libraries are correct including the theItemType
sections for TV Shows and Movies. Because of this, we are still able use a single ViewModel for both existing Library types we have on iOS and tvOS.This PR is based on: #1409 (review)