mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-08 02:34:19 -04:00
Add ExtraType.Unknown enum value and use it instead of null
This commit is contained in:
parent
e266ad51c5
commit
cc8294842a
@ -1057,7 +1057,7 @@ namespace Emby.Server.Implementations.Dto
|
|||||||
if (options.ContainsField(ItemFields.SpecialFeatureCount))
|
if (options.ContainsField(ItemFields.SpecialFeatureCount))
|
||||||
{
|
{
|
||||||
allExtras = item.GetExtras().ToArray();
|
allExtras = item.GetExtras().ToArray();
|
||||||
dto.SpecialFeatureCount = allExtras.Count(i => BaseItem.DisplayExtraTypes.Contains(i.ExtraType));
|
dto.SpecialFeatureCount = allExtras.Count(i => i.ExtraType.HasValue && BaseItem.DisplayExtraTypes.Contains(i.ExtraType.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.ContainsField(ItemFields.LocalTrailerCount))
|
if (options.ContainsField(ItemFields.LocalTrailerCount))
|
||||||
|
@ -381,7 +381,7 @@ namespace MediaBrowser.Api.UserLibrary
|
|||||||
|
|
||||||
var dtoOptions = GetDtoOptions(_authContext, request);
|
var dtoOptions = GetDtoOptions(_authContext, request);
|
||||||
|
|
||||||
var dtosExtras = item.GetExtras(new ExtraType?[] { ExtraType.Trailer })
|
var dtosExtras = item.GetExtras(new ExtraType[] { ExtraType.Trailer })
|
||||||
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
|
.Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
@ -1329,7 +1329,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
// Use some hackery to get the extra type based on foldername
|
// Use some hackery to get the extra type based on foldername
|
||||||
item.ExtraType = Enum.TryParse(extraFolderName.Replace(" ", ""), true, out ExtraType extraType)
|
item.ExtraType = Enum.TryParse(extraFolderName.Replace(" ", ""), true, out ExtraType extraType)
|
||||||
? extraType
|
? extraType
|
||||||
: (ExtraType?)null;
|
: Model.Entities.ExtraType.Unknown;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
|
|
||||||
@ -2896,12 +2896,12 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="extraTypes">The types of extras to retrieve.</param>
|
/// <param name="extraTypes">The types of extras to retrieve.</param>
|
||||||
/// <returns>An enumerable containing the extras.</returns>
|
/// <returns>An enumerable containing the extras.</returns>
|
||||||
public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType?> extraTypes)
|
public IEnumerable<BaseItem> GetExtras(IReadOnlyCollection<ExtraType> extraTypes)
|
||||||
{
|
{
|
||||||
return ExtraIds
|
return ExtraIds
|
||||||
.Select(LibraryManager.GetItemById)
|
.Select(LibraryManager.GetItemById)
|
||||||
.Where(i => i != null)
|
.Where(i => i != null)
|
||||||
.Where(i => extraTypes.Contains(i.ExtraType));
|
.Where(i => i.ExtraType.HasValue && extraTypes.Contains(i.ExtraType.Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<BaseItem> GetTrailers()
|
public IEnumerable<BaseItem> GetTrailers()
|
||||||
@ -2932,10 +2932,9 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extra types that should be counted and displayed as "Special Features" in the UI.
|
/// Extra types that should be counted and displayed as "Special Features" in the UI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly IReadOnlyCollection<ExtraType?> DisplayExtraTypes = new HashSet<ExtraType?>
|
public static readonly IReadOnlyCollection<ExtraType> DisplayExtraTypes = new HashSet<ExtraType>
|
||||||
{
|
{
|
||||||
null,
|
Model.Entities.ExtraType.Unknown,
|
||||||
0,
|
|
||||||
Model.Entities.ExtraType.BehindTheScenes,
|
Model.Entities.ExtraType.BehindTheScenes,
|
||||||
Model.Entities.ExtraType.Clip,
|
Model.Entities.ExtraType.Clip,
|
||||||
Model.Entities.ExtraType.DeletedScene,
|
Model.Entities.ExtraType.DeletedScene,
|
||||||
|
@ -4,6 +4,7 @@ namespace MediaBrowser.Model.Entities
|
|||||||
{
|
{
|
||||||
public enum ExtraType
|
public enum ExtraType
|
||||||
{
|
{
|
||||||
|
Unknown = 0,
|
||||||
Clip = 1,
|
Clip = 1,
|
||||||
Trailer = 2,
|
Trailer = 2,
|
||||||
BehindTheScenes = 3,
|
BehindTheScenes = 3,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user