From fee07219d0f054e33a2a60c84bd66344b42e0c0e Mon Sep 17 00:00:00 2001 From: crobibero Date: Wed, 24 Jun 2020 10:54:25 -0600 Subject: [PATCH] fix merge --- .../Controllers/ChannelsController.cs | 7 +++-- Jellyfin.Api/Extensions/DtoExtensions.cs | 2 +- Jellyfin.Api/Helpers/RequestHelpers.cs | 27 ++----------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/Jellyfin.Api/Controllers/ChannelsController.cs b/Jellyfin.Api/Controllers/ChannelsController.cs index a22cdd7803..c3e29323e3 100644 --- a/Jellyfin.Api/Controllers/ChannelsController.cs +++ b/Jellyfin.Api/Controllers/ChannelsController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Jellyfin.Api.Extensions; using Jellyfin.Api.Helpers; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Dto; @@ -130,7 +131,8 @@ namespace Jellyfin.Api.Controllers ChannelIds = new[] { channelId }, ParentId = folderId ?? Guid.Empty, OrderBy = RequestHelpers.GetOrderBy(sortBy, sortOrder), - DtoOptions = new DtoOptions { Fields = RequestHelpers.GetItemFields(fields) } + DtoOptions = new DtoOptions() + .AddItemFields(fields) }; foreach (var filter in RequestHelpers.GetFilters(filters)) @@ -206,7 +208,8 @@ namespace Jellyfin.Api.Controllers .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(i => new Guid(i)) .ToArray(), - DtoOptions = new DtoOptions { Fields = RequestHelpers.GetItemFields(fields) } + DtoOptions = new DtoOptions() + .AddItemFields(fields) }; foreach (var filter in RequestHelpers.GetFilters(filters)) diff --git a/Jellyfin.Api/Extensions/DtoExtensions.cs b/Jellyfin.Api/Extensions/DtoExtensions.cs index ac248109d7..4c495404f8 100644 --- a/Jellyfin.Api/Extensions/DtoExtensions.cs +++ b/Jellyfin.Api/Extensions/DtoExtensions.cs @@ -23,7 +23,7 @@ namespace Jellyfin.Api.Extensions /// DtoOptions object. /// Comma delimited string of fields. /// Modified DtoOptions object. - internal static DtoOptions AddItemFields(this DtoOptions dtoOptions, string fields) + internal static DtoOptions AddItemFields(this DtoOptions dtoOptions, string? fields) { if (string.IsNullOrEmpty(fields)) { diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index 6e88823914..242f884672 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.Linq; using Jellyfin.Data.Enums; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Querying; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; using Microsoft.AspNetCore.Http; namespace Jellyfin.Api.Helpers @@ -55,29 +55,6 @@ namespace Jellyfin.Api.Helpers return result; } - /// - /// Gets the item fields. - /// - /// The fields. - /// IEnumerable{ItemFields}. - public static ItemFields[] GetItemFields(string? fields) - { - if (string.IsNullOrEmpty(fields)) - { - return Array.Empty(); - } - - return fields.Split(',').Select(v => - { - if (Enum.TryParse(v, true, out ItemFields value)) - { - return (ItemFields?)value; - } - - return null; - }).Where(i => i.HasValue).Select(i => i!.Value).ToArray(); - } - /// /// Get parsed filters. ///