2021-05-06 18:39:20 -04:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 15:56:24 -04:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 15:01:16 -05:00
|
|
|
using System;
|
2018-12-27 18:27:57 -05:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-10-15 11:49:49 -04:00
|
|
|
using System.Text.Json.Serialization;
|
2018-12-27 18:27:57 -05:00
|
|
|
using System.Threading.Tasks;
|
2020-05-20 13:07:53 -04:00
|
|
|
using Jellyfin.Data.Entities;
|
2023-11-09 16:00:29 -05:00
|
|
|
using Jellyfin.Data.Enums;
|
2021-12-20 07:31:07 -05:00
|
|
|
using Jellyfin.Extensions;
|
2019-01-13 14:25:32 -05:00
|
|
|
using MediaBrowser.Controller.TV;
|
|
|
|
using MediaBrowser.Model.Querying;
|
2018-12-27 18:27:57 -05:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Entities
|
|
|
|
{
|
|
|
|
public class UserView : Folder, IHasCollectionType
|
|
|
|
{
|
2023-11-09 16:00:29 -05:00
|
|
|
private static readonly CollectionType?[] _viewTypesEligibleForGrouping =
|
2021-07-11 16:32:06 -04:00
|
|
|
{
|
2023-11-09 16:00:29 -05:00
|
|
|
Jellyfin.Data.Enums.CollectionType.Movies,
|
|
|
|
Jellyfin.Data.Enums.CollectionType.TvShows,
|
|
|
|
null
|
2021-07-11 16:32:06 -04:00
|
|
|
};
|
|
|
|
|
2023-11-09 16:00:29 -05:00
|
|
|
private static readonly CollectionType?[] _originalFolderViewTypes =
|
2021-07-11 16:32:06 -04:00
|
|
|
{
|
2023-11-09 16:00:29 -05:00
|
|
|
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
|
2021-07-11 16:32:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
public static ITVSeriesManager TVSeriesManager { get; set; }
|
|
|
|
|
2021-05-13 09:32:02 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the view type.
|
|
|
|
/// </summary>
|
2023-11-09 16:00:29 -05:00
|
|
|
public CollectionType? ViewType { get; set; }
|
2019-11-01 11:53:16 -04:00
|
|
|
|
2021-05-13 09:32:02 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the display parent id.
|
|
|
|
/// </summary>
|
2018-12-27 16:43:48 -05:00
|
|
|
public new Guid DisplayParentId { get; set; }
|
2018-12-27 18:27:57 -05:00
|
|
|
|
2021-05-13 09:32:02 -04:00
|
|
|
/// <summary>
|
|
|
|
/// Gets or sets the user id.
|
|
|
|
/// </summary>
|
2018-12-27 18:27:57 -05:00
|
|
|
public Guid? UserId { get; set; }
|
|
|
|
|
2019-11-01 11:53:16 -04:00
|
|
|
/// <inheritdoc />
|
2019-10-15 11:49:49 -04:00
|
|
|
[JsonIgnore]
|
2023-11-09 16:00:29 -05:00
|
|
|
public CollectionType? CollectionType => ViewType;
|
2018-12-27 18:27:57 -05:00
|
|
|
|
2021-07-11 16:32:06 -04: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 11:53:16 -04:00
|
|
|
/// <inheritdoc />
|
2018-12-27 18:27:57 -05:00
|
|
|
public override IEnumerable<Guid> GetIdsForAncestorQuery()
|
|
|
|
{
|
2022-02-21 08:15:09 -05:00
|
|
|
if (!DisplayParentId.Equals(default))
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
2019-11-01 11:53:16 -04:00
|
|
|
yield return DisplayParentId;
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
2022-02-21 08:15:09 -05:00
|
|
|
else if (!ParentId.Equals(default))
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
2019-11-01 11:53:16 -04:00
|
|
|
yield return ParentId;
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-01 11:53:16 -04:00
|
|
|
yield return Id;
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2020-05-20 13:07:53 -04:00
|
|
|
public override int GetChildCount(User user)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
return GetChildren(user, true).Count;
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2018-12-27 18:27:57 -05:00
|
|
|
protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
|
|
|
|
{
|
|
|
|
var parent = this as Folder;
|
|
|
|
|
2022-02-21 08:15:09 -05:00
|
|
|
if (!DisplayParentId.Equals(default))
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
|
|
|
|
}
|
2022-02-21 08:15:09 -05:00
|
|
|
else if (!ParentId.Equals(default))
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
|
|
|
|
}
|
|
|
|
|
2021-11-16 06:25:46 -05:00
|
|
|
return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager)
|
2018-12-27 18:27:57 -05:00
|
|
|
.GetUserItems(parent, this, CollectionType, query);
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2020-05-20 13:07:53 -04:00
|
|
|
public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
2021-05-05 07:51:14 -04:00
|
|
|
query ??= new InternalItemsQuery(user);
|
2018-12-27 18:27:57 -05:00
|
|
|
|
|
|
|
query.EnableTotalRecordCount = false;
|
|
|
|
var result = GetItemList(query);
|
|
|
|
|
|
|
|
return result.ToList();
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2018-12-27 18:27:57 -05:00
|
|
|
public override bool CanDelete()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2018-12-27 18:27:57 -05:00
|
|
|
public override bool IsSaveLocalMetadataEnabled()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2020-05-20 13:07:53 -04:00
|
|
|
public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
query.SetUser(user);
|
|
|
|
query.Recursive = true;
|
|
|
|
query.EnableTotalRecordCount = false;
|
|
|
|
query.ForceDirect = true;
|
|
|
|
|
|
|
|
return GetItemList(query);
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
/// <inheritdoc />
|
2020-05-20 13:07:53 -04:00
|
|
|
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
return GetChildren(user, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsUserSpecific(Folder folder)
|
|
|
|
{
|
2021-07-11 16:32:06 -04:00
|
|
|
if (folder is not ICollectionFolder collectionFolder)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-07-11 16:32:06 -04:00
|
|
|
if (folder is ISupportsUserSpecificView supportsUserSpecific
|
|
|
|
&& supportsUserSpecific.EnableUserSpecificView)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-11-09 16:00:29 -05:00
|
|
|
return collectionFolder.CollectionType == Jellyfin.Data.Enums.CollectionType.Playlists;
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static bool IsEligibleForGrouping(Folder folder)
|
|
|
|
{
|
2018-12-27 16:43:48 -05:00
|
|
|
return folder is ICollectionFolder collectionFolder
|
|
|
|
&& IsEligibleForGrouping(collectionFolder.CollectionType);
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
2023-11-09 16:00:29 -05:00
|
|
|
public static bool IsEligibleForGrouping(CollectionType? viewType)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
2023-11-09 16:00:29 -05:00
|
|
|
return _viewTypesEligibleForGrouping.Contains(viewType);
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
2023-11-09 16:00:29 -05:00
|
|
|
public static bool EnableOriginalFolder(CollectionType? viewType)
|
2018-12-27 18:27:57 -05:00
|
|
|
{
|
2023-11-09 16:00:29 -05:00
|
|
|
return _originalFolderViewTypes.Contains(viewType);
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
2021-06-06 11:16:41 -04: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 18:27:57 -05:00
|
|
|
{
|
2018-12-27 16:43:48 -05:00
|
|
|
return Task.CompletedTask;
|
2018-12-27 18:27:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|