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

189 lines
5.7 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.Data.Enums;
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 CollectionType?[] _viewTypesEligibleForGrouping =
{
Jellyfin.Data.Enums.CollectionType.Movies,
Jellyfin.Data.Enums.CollectionType.TvShows,
null
};
private static readonly CollectionType?[] _originalFolderViewTypes =
{
Jellyfin.Data.Enums.CollectionType.Books,
Jellyfin.Data.Enums.CollectionType.MusicVideos,
Jellyfin.Data.Enums.CollectionType.HomeVideos,
Jellyfin.Data.Enums.CollectionType.Photos,
Jellyfin.Data.Enums.CollectionType.Music,
Jellyfin.Data.Enums.CollectionType.BoxSets
};
public static ITVSeriesManager TVSeriesManager { get; set; }
/// <summary>
/// Gets or sets the view type.
/// </summary>
public CollectionType? 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 CollectionType? 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(default))
6 years ago
{
yield return DisplayParentId;
6 years ago
}
else if (!ParentId.Equals(default))
6 years ago
{
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(default))
6 years ago
{
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
}
else if (!ParentId.Equals(default))
6 years ago
{
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 collectionFolder.CollectionType == Jellyfin.Data.Enums.CollectionType.Playlists;
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(CollectionType? viewType)
6 years ago
{
return _viewTypesEligibleForGrouping.Contains(viewType);
6 years ago
}
public static bool EnableOriginalFolder(CollectionType? viewType)
6 years ago
{
return _originalFolderViewTypes.Contains(viewType);
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
}
}
}