Browse Source

Revert limit hack (#14820)

JPVenson 4 days ago
parent
commit
59f77c24c9
1 changed files with 5 additions and 5 deletions
  1. 5 5
      MediaBrowser.Controller/Entities/Folder.cs

+ 5 - 5
MediaBrowser.Controller/Entities/Folder.cs

@@ -1333,8 +1333,8 @@ namespace MediaBrowser.Controller.Entities
         private int AddChildrenFromCollection(IEnumerable<BaseItem> children, User user, bool includeLinkedChildren, Dictionary<Guid, BaseItem> result, bool recursive, InternalItemsQuery query, HashSet<Folder> visitedFolders)
         private int AddChildrenFromCollection(IEnumerable<BaseItem> children, User user, bool includeLinkedChildren, Dictionary<Guid, BaseItem> result, bool recursive, InternalItemsQuery query, HashSet<Folder> visitedFolders)
         {
         {
             query ??= new InternalItemsQuery();
             query ??= new InternalItemsQuery();
-            var limit = query.Limit;
-            query.Limit = 100; // this is a bit of a dirty hack thats in favor of specifically the webUI as it does not show more then +99 elements in its badges so there is no point in reading more then that.
+            var limit = query.Limit > 0 ? query.Limit : int.MaxValue;
+            query.Limit = 0;
 
 
             var visibileChildren = children
             var visibileChildren = children
                 .Where(e => e.IsVisible(user))
                 .Where(e => e.IsVisible(user))
@@ -1343,12 +1343,12 @@ namespace MediaBrowser.Controller.Entities
             var realChildren = visibileChildren
             var realChildren = visibileChildren
                 .Where(e => query is null || UserViewBuilder.FilterItem(e, query))
                 .Where(e => query is null || UserViewBuilder.FilterItem(e, query))
                 .ToArray();
                 .ToArray();
-            var childCount = realChildren.Count();
-            if (result.Count < query.Limit)
+            var childCount = realChildren.Length;
+            if (result.Count < limit)
             {
             {
                 foreach (var child in realChildren
                 foreach (var child in realChildren
                     .Skip(query.StartIndex ?? 0)
                     .Skip(query.StartIndex ?? 0)
-                    .TakeWhile(e => query.Limit >= result.Count))
+                    .TakeWhile(e => limit > result.Count))
                 {
                 {
                     result[child.Id] = child;
                     result[child.Id] = child;
                 }
                 }