mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-11-21 07:12:24 +00:00
Stop /UserViews resolving every box set in a collections library
This commit is contained in:
parent
2a43776881
commit
596be45f85
2 changed files with 32 additions and 7 deletions
|
|
@ -60,7 +60,16 @@ namespace Emby.Server.Implementations.Library
|
|||
var folderViewType = collectionFolder?.CollectionType;
|
||||
|
||||
// Playlist and BoxSet libraries require special handling because the folder only references linked items
|
||||
if (folderViewType == CollectionType.playlists || folderViewType == CollectionType.boxsets)
|
||||
if (folderViewType == CollectionType.boxsets)
|
||||
{
|
||||
// Only the existence of one visible box set matters here, so probe the children
|
||||
// lazily and stop at the first hit.
|
||||
if (!folder.Children.Any(item => item.IsVisible(user)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (folderViewType == CollectionType.playlists)
|
||||
{
|
||||
var items = folder.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -168,14 +168,21 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
return true;
|
||||
}
|
||||
|
||||
var userLibraryFolderIds = GetLibraryFolderIds(user);
|
||||
var libraryFolderIds = LibraryFolderIds ?? GetLibraryFolderIds();
|
||||
List<BaseItem> linkedItems = null;
|
||||
var libraryFolderIds = LibraryFolderIds;
|
||||
if (libraryFolderIds is null)
|
||||
{
|
||||
linkedItems = GetLinkedChildren();
|
||||
libraryFolderIds = GetLibraryFolderIds(linkedItems);
|
||||
}
|
||||
|
||||
if (libraryFolderIds.Length == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var userLibraryFolderIds = GetLibraryFolderIds(user);
|
||||
|
||||
if (!userLibraryFolderIds.Any(i => libraryFolderIds.Contains(i)))
|
||||
{
|
||||
return false;
|
||||
|
|
@ -184,7 +191,7 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
// If user has parental controls, hide the BoxSet when all children are restricted
|
||||
if (user.MaxParentalRatingScore.HasValue)
|
||||
{
|
||||
var linkedItems = GetLinkedChildren();
|
||||
linkedItems ??= GetLinkedChildren();
|
||||
if (linkedItems.Count > 0 && linkedItems.All(child => !child.IsParentalAllowed(user, true)))
|
||||
{
|
||||
return false;
|
||||
|
|
@ -241,10 +248,19 @@ namespace MediaBrowser.Controller.Entities.Movies
|
|||
|
||||
public Guid[] GetLibraryFolderIds()
|
||||
{
|
||||
var expandedFolders = new List<Guid>();
|
||||
return GetLibraryFolderIds(GetLinkedChildren());
|
||||
}
|
||||
|
||||
return FlattenItems(this, expandedFolders)
|
||||
.SelectMany(LibraryManager.GetCollectionFolders)
|
||||
private Guid[] GetLibraryFolderIds(IEnumerable<BaseItem> linkedChildren)
|
||||
{
|
||||
// Seeded with this box set so a cycle through a nested collection terminates.
|
||||
var expandedFolders = new List<Guid> { Id };
|
||||
|
||||
// The user root children are the same for every item.
|
||||
var rootChildren = LibraryManager.GetUserRootFolder().Children.OfType<Folder>().ToList();
|
||||
|
||||
return FlattenItems(linkedChildren, expandedFolders)
|
||||
.SelectMany(i => LibraryManager.GetCollectionFolders(i, rootChildren))
|
||||
.Select(i => i.Id)
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue