Backport pull request #15187 from jellyfin/release-10.11.z
Fix pagination and sorting for folders
Original-merge: 7d1824ea27
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Bond_009 <bond.009@outlook.com>
This commit is contained in:
@@ -715,9 +715,18 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
items = GetRecursiveChildren(user, query, out totalCount);
|
// Save pagination params before clearing them to prevent pagination from happening
|
||||||
|
// before sorting. PostFilterAndSort will apply pagination after sorting.
|
||||||
|
var limit = query.Limit;
|
||||||
|
var startIndex = query.StartIndex;
|
||||||
query.Limit = null;
|
query.Limit = null;
|
||||||
query.StartIndex = null; // override these here as they have already been applied
|
query.StartIndex = null;
|
||||||
|
|
||||||
|
items = GetRecursiveChildren(user, query, out totalCount);
|
||||||
|
|
||||||
|
// Restore pagination params so PostFilterAndSort can apply them after sorting
|
||||||
|
query.Limit = limit;
|
||||||
|
query.StartIndex = startIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = PostFilterAndSort(items, query);
|
var result = PostFilterAndSort(items, query);
|
||||||
@@ -980,20 +989,16 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// need to pass this param to the children.
|
// need to pass this param to the children.
|
||||||
|
// Note: Don't pass Limit/StartIndex here as pagination should happen after sorting in PostFilterAndSort
|
||||||
var childQuery = new InternalItemsQuery
|
var childQuery = new InternalItemsQuery
|
||||||
{
|
{
|
||||||
DisplayAlbumFolders = query.DisplayAlbumFolders,
|
DisplayAlbumFolders = query.DisplayAlbumFolders,
|
||||||
Limit = query.Limit,
|
|
||||||
StartIndex = query.StartIndex,
|
|
||||||
NameStartsWith = query.NameStartsWith,
|
NameStartsWith = query.NameStartsWith,
|
||||||
NameStartsWithOrGreater = query.NameStartsWithOrGreater,
|
NameStartsWithOrGreater = query.NameStartsWithOrGreater,
|
||||||
NameLessThan = query.NameLessThan
|
NameLessThan = query.NameLessThan
|
||||||
};
|
};
|
||||||
|
|
||||||
items = GetChildren(user, true, out totalItemCount, childQuery).Where(filter);
|
items = GetChildren(user, true, out totalItemCount, childQuery).Where(filter);
|
||||||
|
|
||||||
query.Limit = null;
|
|
||||||
query.StartIndex = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = PostFilterAndSort(items, query);
|
var result = PostFilterAndSort(items, query);
|
||||||
|
|||||||
Reference in New Issue
Block a user