2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-10-15 15:49:49 +00:00
|
|
|
using System.Text.Json.Serialization;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Threading.Tasks;
|
2020-05-20 17:07:53 +00:00
|
|
|
using Jellyfin.Data.Entities;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Controller.TV;
|
|
|
|
using MediaBrowser.Model.Querying;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
{
|
|
|
|
public class UserView : Folder, IHasCollectionType
|
|
|
|
{
|
2021-07-11 20:32:06 +00:00
|
|
|
private static readonly string[] _viewTypesEligibleForGrouping = new string[]
|
|
|
|
{
|
|
|
|
Model.Entities.CollectionType.Movies,
|
|
|
|
Model.Entities.CollectionType.TvShows,
|
|
|
|
string.Empty
|
|
|
|
};
|
|
|
|
|
|
|
|
private static readonly string[] _originalFolderViewTypes = new string[]
|
|
|
|
{
|
|
|
|
Model.Entities.CollectionType.Books,
|
|
|
|
Model.Entities.CollectionType.MusicVideos,
|
|
|
|
Model.Entities.CollectionType.HomeVideos,
|
|
|
|
Model.Entities.CollectionType.Photos,
|
|
|
|
Model.Entities.CollectionType.Music,
|
|
|
|
Model.Entities.CollectionType.BoxSets
|
|
|
|
};
|
|
|
|
|
|
|
|
public static ITVSeriesManager TVSeriesManager { get; set; }
|
|
|
|
|
2021-05-13 13:32:02 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the view type.
|
|
|
|
/// </summary>
|
2018-12-27 23:27:57 +00:00
|
|
|
public string ViewType { get; set; }
|
2019-11-01 15:53:16 +00:00
|
|
|
|
2021-05-13 13:32:02 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the display parent id.
|
|
|
|
/// </summary>
|
2018-12-27 21:43:48 +00:00
|
|
|
public new Guid DisplayParentId { get; set; }
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2021-05-13 13:32:02 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
/// </summary>
|
2018-12-27 23:27:57 +00:00
|
|
|
public Guid? UserId { get; set; }
|
|
|
|
|
2019-11-01 15:53:16 +00:00
|
|
|
/// <inheritdoc />
|
2019-10-15 15:49:49 +00:00
|
|
|
[JsonIgnore]
|
2019-01-13 20:31:14 +00:00
|
|
|
public string CollectionType => ViewType;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
|
|
|
[JsonIgnore]
|
|
|
|
public override bool SupportsInheritedParentImages => false;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[JsonIgnore]
|
|
|
|
public override bool SupportsPlayedStatus => false;
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
[JsonIgnore]
|
|
|
|
public override bool SupportsPeople => false;
|
|
|
|
|
2019-11-01 15:53:16 +00:00
|
|
|
/// <inheritdoc />
|
2018-12-27 23:27:57 +00:00
|
|
|
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
|
|
|
{
|
|
|
|
if (!DisplayParentId.Equals(Guid.Empty))
|
|
|
|
{
|
2019-11-01 15:53:16 +00:00
|
|
|
yield return DisplayParentId;
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
else if (!ParentId.Equals(Guid.Empty))
|
|
|
|
{
|
2019-11-01 15:53:16 +00:00
|
|
|
yield return ParentId;
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-01 15:53:16 +00:00
|
|
|
yield return Id;
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2020-05-20 17:07:53 +00:00
|
|
|
public override int GetChildCount(User user)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
return GetChildren(user, true).Count;
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2018-12-27 23:27:57 +00:00
|
|
|
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
|
|
|
|
{
|
|
|
|
var parent = this as Folder;
|
|
|
|
|
|
|
|
if (!DisplayParentId.Equals(Guid.Empty))
|
|
|
|
{
|
|
|
|
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
|
|
|
|
}
|
|
|
|
else if (!ParentId.Equals(Guid.Empty))
|
|
|
|
{
|
|
|
|
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
|
|
|
|
}
|
|
|
|
|
2021-11-16 11:25:46 +00:00
|
|
|
return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager)
|
2018-12-27 23:27:57 +00:00
|
|
|
.GetUserItems(parent, this, CollectionType, query);
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2020-05-20 17:07:53 +00:00
|
|
|
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
2021-05-05 11:51:14 +00:00
|
|
|
query ??= new InternalItemsQuery(user);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
query.EnableTotalRecordCount = false;
|
|
|
|
var result = GetItemList(query);
|
|
|
|
|
|
|
|
return result.ToList();
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2018-12-27 23:27:57 +00:00
|
|
|
public override bool CanDelete()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2018-12-27 23:27:57 +00:00
|
|
|
public override bool IsSaveLocalMetadataEnabled()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2020-05-20 17:07:53 +00:00
|
|
|
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
query.SetUser(user);
|
|
|
|
query.Recursive = true;
|
|
|
|
query.EnableTotalRecordCount = false;
|
|
|
|
query.ForceDirect = true;
|
|
|
|
|
|
|
|
return GetItemList(query);
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
/// <inheritdoc />
|
2020-05-20 17:07:53 +00:00
|
|
|
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
return GetChildren(user, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsUserSpecific(Folder folder)
|
|
|
|
{
|
2021-07-11 20:32:06 +00:00
|
|
|
if (folder is not ICollectionFolder collectionFolder)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
if (folder is ISupportsUserSpecificView supportsUserSpecific
|
|
|
|
&& supportsUserSpecific.EnableUserSpecificView)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-11 20:32:06 +00:00
|
|
|
return string.Equals(Model.Entities.CollectionType.Playlists, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsEligibleForGrouping(Folder folder)
|
|
|
|
{
|
2018-12-27 21:43:48 +00:00
|
|
|
return folder is ICollectionFolder collectionFolder
|
|
|
|
&& IsEligibleForGrouping(collectionFolder.CollectionType);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsEligibleForGrouping(string viewType)
|
|
|
|
{
|
2021-07-11 20:32:06 +00:00
|
|
|
return _viewTypesEligibleForGrouping.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static bool EnableOriginalFolder(string viewType)
|
|
|
|
{
|
2021-07-11 20:32:06 +00:00
|
|
|
return _originalFolderViewTypes.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 15:16:41 +00:00
|
|
|
protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService, System.Threading.CancellationToken cancellationToken)
|
2018-12-27 23:27:57 +00:00
|
|
|
{
|
2018-12-27 21:43:48 +00:00
|
|
|
return Task.CompletedTask;
|
2018-12-27 23:27:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|