You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Entities/UserView.cs

188 lines
5.8 KiB

#nullable disable
#pragma warning disable CS1591
using System;
6 years ago
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
6 years ago
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Extensions;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Querying;
6 years ago
namespace MediaBrowser.Controller.Entities
{
public class UserView : Folder, IHasCollectionType
{
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; }
/// <summary>
/// Gets or sets the view type.
/// </summary>
6 years ago
public string ViewType { get; set; }
/// <summary>
/// Gets or sets the display parent id.
/// </summary>
6 years ago
public new Guid DisplayParentId { get; set; }
6 years ago
/// <summary>
/// Gets or sets the user id.
/// </summary>
6 years ago
public Guid? UserId { get; set; }
/// <inheritdoc />
[JsonIgnore]
public string CollectionType => ViewType;
6 years ago
/// <inheritdoc />
[JsonIgnore]
public override bool SupportsInheritedParentImages => false;
/// <inheritdoc />
[JsonIgnore]
public override bool SupportsPlayedStatus => false;
/// <inheritdoc />
[JsonIgnore]
public override bool SupportsPeople => false;
/// <inheritdoc />
6 years ago
public override IEnumerable<Guid> GetIdsForAncestorQuery()
{
if (!DisplayParentId.Equals(Guid.Empty))
{
yield return DisplayParentId;
6 years ago
}
else if (!ParentId.Equals(Guid.Empty))
{
yield return ParentId;
6 years ago
}
else
{
yield return Id;
6 years ago
}
}
/// <inheritdoc />
public override int GetChildCount(User user)
6 years ago
{
return GetChildren(user, true).Count;
}
/// <inheritdoc />
6 years ago
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;
}
3 years ago
return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager)
6 years ago
.GetUserItems(parent, this, CollectionType, query);
}
/// <inheritdoc />
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
6 years ago
{
query ??= new InternalItemsQuery(user);
6 years ago
query.EnableTotalRecordCount = false;
var result = GetItemList(query);
return result.ToList();
}
/// <inheritdoc />
6 years ago
public override bool CanDelete()
{
return false;
}
/// <inheritdoc />
6 years ago
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
/// <inheritdoc />
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
6 years ago
{
query.SetUser(user);
query.Recursive = true;
query.EnableTotalRecordCount = false;
query.ForceDirect = true;
return GetItemList(query);
}
/// <inheritdoc />
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
6 years ago
{
return GetChildren(user, false);
}
public static bool IsUserSpecific(Folder folder)
{
if (folder is not ICollectionFolder collectionFolder)
6 years ago
{
return false;
}
if (folder is ISupportsUserSpecificView supportsUserSpecific
&& supportsUserSpecific.EnableUserSpecificView)
6 years ago
{
return true;
}
return string.Equals(Model.Entities.CollectionType.Playlists, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase);
6 years ago
}
public static bool IsEligibleForGrouping(Folder folder)
{
6 years ago
return folder is ICollectionFolder collectionFolder
&& IsEligibleForGrouping(collectionFolder.CollectionType);
6 years ago
}
public static bool IsEligibleForGrouping(string viewType)
{
return _viewTypesEligibleForGrouping.Contains(viewType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
6 years ago
}
public static bool EnableOriginalFolder(string viewType)
{
return _originalFolderViewTypes.Contains(viewType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
6 years ago
}
protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService, System.Threading.CancellationToken cancellationToken)
6 years ago
{
6 years ago
return Task.CompletedTask;
6 years ago
}
}
}