Fix BoxSet collapse handling and deletion

This commit is contained in:
Shadowghost
2026-02-07 21:17:01 +01:00
parent 2420ece5fe
commit bb6c3b4eec
5 changed files with 179 additions and 14 deletions

View File

@@ -79,14 +79,27 @@ namespace MediaBrowser.Controller.Entities
public CollectionType? CollectionType { get; set; }
/// <summary>
/// Gets the item's children.
/// Gets or sets the item's children.
/// </summary>
/// <remarks>
/// Our children are actually just references to the ones in the physical root...
/// Setting to null propagates invalidation to physical folders since the getter
/// always delegates to <see cref="GetActualChildren"/> and never reads the backing field.
/// </remarks>
/// <value>The actual children.</value>
[JsonIgnore]
public override IEnumerable<BaseItem> Children => GetActualChildren();
public override IEnumerable<BaseItem> Children
{
get => GetActualChildren();
set
{
// The getter delegates to physical folders, so invalidate their caches.
foreach (var folder in GetPhysicalFolders(true))
{
folder.Children = null;
}
}
}
[JsonIgnore]
public override bool SupportsPeople => false;

View File

@@ -733,6 +733,7 @@ namespace MediaBrowser.Controller.Entities
if (!query.ForceDirect && RequiresPostFiltering(query))
{
query.CollapseBoxSetItems = true;
SetCollapseBoxSetItemTypes(query);
}
if (this is not UserRootFolder
@@ -1039,6 +1040,33 @@ namespace MediaBrowser.Controller.Entities
return (queryHasMovies || queryHasSeries) && AllowBoxSetCollapsing(query);
}
private void SetCollapseBoxSetItemTypes(InternalItemsQuery query)
{
var config = ConfigurationManager.Configuration;
bool collapseMovies = config.EnableGroupingMoviesIntoCollections;
bool collapseSeries = config.EnableGroupingShowsIntoCollections;
if (collapseMovies && collapseSeries)
{
// Empty means collapse all types
query.CollapseBoxSetItemTypes = [];
return;
}
var types = new List<BaseItemKind>();
if (collapseMovies)
{
types.Add(BaseItemKind.Movie);
}
if (collapseSeries)
{
types.Add(BaseItemKind.Series);
}
query.CollapseBoxSetItemTypes = types.ToArray();
}
private static bool AllowBoxSetCollapsing(InternalItemsQuery request)
{
if (request.IsFavorite.HasValue)

View File

@@ -113,6 +113,12 @@ namespace MediaBrowser.Controller.Entities
public bool? CollapseBoxSetItems { get; set; }
/// <summary>
/// Gets or sets the item types that should be collapsed into box sets.
/// When empty, all types are collapsed. When set, only items of these types are replaced by their parent box set.
/// </summary>
public BaseItemKind[] CollapseBoxSetItemTypes { get; set; } = [];
public string? NameStartsWithOrGreater { get; set; }
public string? NameStartsWith { get; set; }