aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBond-009 <bond.009@outlook.com>2024-08-24 00:00:48 +0200
committerGitHub <noreply@github.com>2024-08-24 00:00:48 +0200
commit549c01c7365ee738be9e5bb911d37804508c73fb (patch)
tree093b83eb91e120cbe3e1df93c3ad3cd8738b224b
parente21144503494137e6f126737a2b6d3f2398e3663 (diff)
parent4344b951a69926df52a41e054c6ffa4ac164fa64 (diff)
Merge pull request #12457 from lostb1t/feature/boxset-sort
Add support for ItemSortBy values in BoxSet
-rw-r--r--MediaBrowser.Controller/Entities/Movies/BoxSet.cs32
1 files changed, 13 insertions, 19 deletions
diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
index d7ccfd8ae..a07187d2f 100644
--- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
+++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs
@@ -112,37 +112,31 @@ namespace MediaBrowser.Controller.Entities.Movies
return true;
}
- public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
+ private IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user)
{
- var children = base.GetChildren(user, includeLinkedChildren, query);
-
- if (string.Equals(DisplayOrder, "SortName", StringComparison.OrdinalIgnoreCase))
+ if (!Enum.TryParse<ItemSortBy>(DisplayOrder, out var sortBy))
{
- // Sort by name
- return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList();
+ sortBy = ItemSortBy.PremiereDate;
}
- if (string.Equals(DisplayOrder, "PremiereDate", StringComparison.OrdinalIgnoreCase))
+ if (sortBy == ItemSortBy.Default)
{
- // Sort by release date
- return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList();
+ return items;
}
- // Default sorting
- return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList();
+ return LibraryManager.Sort(items, user, new[] { 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()