aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Collections/CollectionManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-22 11:41:34 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2015-01-22 11:41:34 -0500
commitb7e5e21c975cc4953764d48c1dacbcd4dc149de9 (patch)
tree1bf66f65eb3a11b095b83c2d116fd70db919ba27 /MediaBrowser.Server.Implementations/Collections/CollectionManager.cs
parent7bc370bdc72df5dac395b8fee805284b845ed911 (diff)
update task buttons
Diffstat (limited to 'MediaBrowser.Server.Implementations/Collections/CollectionManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Collections/CollectionManager.cs64
1 files changed, 27 insertions, 37 deletions
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<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user)
{
- var itemsToCollapse = new List<ISupportsBoxSetGrouping>();
- var boxsets = new List<BaseItem>();
+ var results = new Dictionary<Guid, BaseItem>();
+ var allBoxsets = new List<BoxSet>();
- var list = items.ToList();
-
- foreach (var item in list.OfType<ISupportsBoxSetGrouping>())
+ 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<BaseItem>())
- .Concat(boxsets)
- .DistinctBy(i => i.Id);
+ return results.Values;
}
}
}