Hiding of root folders
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-12-02 11:28:45 +01:00
parent 3b7f62a1b8
commit 7dbc17ec14
2 changed files with 35 additions and 4 deletions

View File

@@ -167,7 +167,8 @@ public abstract class CinemaFilterFolder : Folder
{
folder.ParentId = Guid.Empty;
folder.IsRoot = true;
CinemaHost.LibraryManager.RootFolder.AddVirtualChild(folder);
if (!CinemaHost.LibraryManager.RootFolder.VirtualChildren.Contains(folder))
CinemaHost.LibraryManager.RootFolder.AddVirtualChild(folder);
}
else
{

View File

@@ -18,6 +18,7 @@ namespace Jellyfin.Plugin.Cinema;
/// </summary>
public abstract class CinemaRootFolder : CinemaFilterFolder, ICollectionFolder
{
private bool _hidden;
/// <summary>
/// Gets the item type for <see cref="ICollectionFolder"/>. Shall be kept in
@@ -25,12 +26,41 @@ public abstract class CinemaRootFolder : CinemaFilterFolder, ICollectionFolder
/// </summary>
public abstract CollectionType? CollectionType { get; }
public override bool IsHidden => Hide;
internal bool Hide { get; set; }
public override bool IsHidden => _hidden;
internal bool Hide
{
get => _hidden;
set
{
var a = CinemaHost.LibraryManager.RootFolder.VirtualChildren;
if (a.Contains(this) == (!value))
return;
if (value)
{
// Remove ourselves
var temp = new List<BaseItem>();
while (!a.IsEmpty)
{
if (!a.TryTake(out BaseItem? b))
continue;
if (b == this)
break;
temp.Add(b);
}
foreach (var i in temp)
a.Add(i);
}
else
// Add ourselves
a.Add(this);
}
}
/*
public Task<DynamicImageResponse> GetChannelImage(ImageType type, CancellationToken cancellationToken)
{
if (type == ImageType.Primary)