diff options
| author | lostb1t <coding-mosses0z@icloud.com> | 2024-08-16 17:01:53 +0200 |
|---|---|---|
| committer | lostb1t <coding-mosses0z@icloud.com> | 2024-08-16 17:01:53 +0200 |
| commit | f737fad43aac6575695679986f24f24b89c9e904 (patch) | |
| tree | 671380c8ced687e53e5c7731e164e6f573b33f89 | |
| parent | ffecdfc18cbe4e97f6812f00ee97364c99fc5726 (diff) | |
Rework get children functions to support ItemSortBy values
| -rw-r--r-- | MediaBrowser.Controller/Entities/Movies/BoxSet.cs | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index d7ccfd8ae..abd1a2a54 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -112,37 +112,35 @@ namespace MediaBrowser.Controller.Entities.Movies return true; } - public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query) + public IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user) { - var children = base.GetChildren(user, includeLinkedChildren, query); - - if (string.Equals(DisplayOrder, "SortName", StringComparison.OrdinalIgnoreCase)) + var sortBy = new[] { - // Sort by name - return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList(); - } - - if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase)) + ItemSortBy.ProductionYear, + ItemSortBy.PremiereDate, + ItemSortBy.SortName + }; + if (!string.IsNullOrEmpty(DisplayOrder)) { - // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); + sortBy = new[] + { + Enum.Parse<ItemSortBy>(DisplayOrder) + }; } - // Default sorting - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); + return LibraryManager.Sort(items, user, sortBy, SortOrder.Ascending); + } + + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query) + { + var children = base.GetChildren(user, includeLinkedChildren, query); + return Sort(children, user).ToList(); } public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query) { var children = base.GetRecursiveChildren(user, query); - - if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase)) - { - // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); - } - - return children; + return Sort(children, user).ToList(); } public BoxSetInfo GetLookupInfo() |
