From b7e5e21c975cc4953764d48c1dacbcd4dc149de9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 22 Jan 2015 11:41:34 -0500 Subject: update task buttons --- .../Collections/CollectionManager.cs | 64 +++++++++------------- 1 file changed, 27 insertions(+), 37 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Collections/CollectionManager.cs') diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs index d92db34e3..6100e3f5d 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs @@ -167,18 +167,6 @@ namespace MediaBrowser.Server.Implementations.Collections } list.Add(LinkedChild.Create(item)); - - var supportsGrouping = item as ISupportsBoxSetGrouping; - - if (supportsGrouping != null) - { - var boxsetIdList = supportsGrouping.BoxSetIdList.ToList(); - if (!boxsetIdList.Contains(collectionId)) - { - boxsetIdList.Add(collectionId); - } - supportsGrouping.BoxSetIdList = boxsetIdList; - } } collection.LinkedChildren.AddRange(list); @@ -228,15 +216,6 @@ namespace MediaBrowser.Server.Implementations.Collections { itemList.Add(childItem); } - - var supportsGrouping = childItem as ISupportsBoxSetGrouping; - - if (supportsGrouping != null) - { - var boxsetIdList = supportsGrouping.BoxSetIdList.ToList(); - boxsetIdList.Remove(collectionId); - supportsGrouping.BoxSetIdList = boxsetIdList; - } } var shortcutFiles = Directory @@ -289,29 +268,40 @@ namespace MediaBrowser.Server.Implementations.Collections public IEnumerable CollapseItemsWithinBoxSets(IEnumerable items, User user) { - var itemsToCollapse = new List(); - var boxsets = new List(); + var results = new Dictionary(); + var allBoxsets = new List(); - var list = items.ToList(); - - foreach (var item in list.OfType()) + foreach (var item in items) { - var currentBoxSets = item.BoxSetIdList - .Select(i => _libraryManager.GetItemById(i)) - .Where(i => i != null && i.IsVisible(user)) - .ToList(); + var grouping = item as ISupportsBoxSetGrouping; - if (currentBoxSets.Count > 0) + if (grouping == null) + { + results[item.Id] = item; + } + else { - itemsToCollapse.Add(item); - boxsets.AddRange(currentBoxSets); + var itemId = item.Id; + + var currentBoxSets = allBoxsets + .Where(i => i.GetLinkedChildren().Any(j => j.Id == itemId)) + .ToList(); + + if (currentBoxSets.Count > 0) + { + foreach (var boxset in currentBoxSets) + { + results[boxset.Id] = boxset; + } + } + else + { + results[item.Id] = item; + } } } - return list - .Except(itemsToCollapse.Cast()) - .Concat(boxsets) - .DistinctBy(i => i.Id); + return results.Values; } } } -- cgit v1.2.3