Convert CollectionType, SpecialFolderType to enum (#9764)

* Convert CollectionType, SpecialFolderType to enum

* Hide internal enum CollectionType values

* Apply suggestions from code review

Co-authored-by: Shadowghost <Shadowghost@users.noreply.github.com>

* Fix recent change

* Update Jellyfin.Data/Attributes/OpenApiIgnoreEnumAttribute.cs

Co-authored-by: Patrick Barron <barronpm@gmail.com>

---------

Co-authored-by: Shadowghost <Shadowghost@users.noreply.github.com>
Co-authored-by: Patrick Barron <barronpm@gmail.com>
This commit is contained in:
Cody Robibero
2023-11-09 14:00:29 -07:00
committed by GitHub
parent c7a94d48ae
commit 906f701fa8
43 changed files with 486 additions and 288 deletions

View File

@@ -8,6 +8,7 @@ using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using Jellyfin.Extensions;
using MediaBrowser.Controller.TV;
using MediaBrowser.Model.Querying;
@@ -16,21 +17,21 @@ namespace MediaBrowser.Controller.Entities
{
public class UserView : Folder, IHasCollectionType
{
private static readonly string[] _viewTypesEligibleForGrouping = new string[]
private static readonly CollectionType?[] _viewTypesEligibleForGrouping =
{
Model.Entities.CollectionType.Movies,
Model.Entities.CollectionType.TvShows,
string.Empty
Jellyfin.Data.Enums.CollectionType.Movies,
Jellyfin.Data.Enums.CollectionType.TvShows,
null
};
private static readonly string[] _originalFolderViewTypes = new string[]
private static readonly CollectionType?[] _originalFolderViewTypes =
{
Model.Entities.CollectionType.Books,
Model.Entities.CollectionType.MusicVideos,
Model.Entities.CollectionType.HomeVideos,
Model.Entities.CollectionType.Photos,
Model.Entities.CollectionType.Music,
Model.Entities.CollectionType.BoxSets
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; }
@@ -38,7 +39,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Gets or sets the view type.
/// </summary>
public string ViewType { get; set; }
public CollectionType? ViewType { get; set; }
/// <summary>
/// Gets or sets the display parent id.
@@ -52,7 +53,7 @@ namespace MediaBrowser.Controller.Entities
/// <inheritdoc />
[JsonIgnore]
public string CollectionType => ViewType;
public CollectionType? CollectionType => ViewType;
/// <inheritdoc />
[JsonIgnore]
@@ -160,7 +161,7 @@ namespace MediaBrowser.Controller.Entities
return true;
}
return string.Equals(Model.Entities.CollectionType.Playlists, collectionFolder.CollectionType, StringComparison.OrdinalIgnoreCase);
return collectionFolder.CollectionType == Jellyfin.Data.Enums.CollectionType.Playlists;
}
public static bool IsEligibleForGrouping(Folder folder)
@@ -169,14 +170,14 @@ namespace MediaBrowser.Controller.Entities
&& IsEligibleForGrouping(collectionFolder.CollectionType);
}
public static bool IsEligibleForGrouping(string viewType)
public static bool IsEligibleForGrouping(CollectionType? viewType)
{
return _viewTypesEligibleForGrouping.Contains(viewType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
return _viewTypesEligibleForGrouping.Contains(viewType);
}
public static bool EnableOriginalFolder(string viewType)
public static bool EnableOriginalFolder(CollectionType? viewType)
{
return _originalFolderViewTypes.Contains(viewType ?? string.Empty, StringComparison.OrdinalIgnoreCase);
return _originalFolderViewTypes.Contains(viewType);
}
protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMetadata, Providers.MetadataRefreshOptions refreshOptions, Providers.IDirectoryService directoryService, System.Threading.CancellationToken cancellationToken)