The Free Software Media System - Server Backend & API
Remove ordering items
Bond-0091731bf7372a1
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.csindex 2233d3d40c..7b28a22a84 100644--- a/Emby.Server.Implementations/Dto/DtoService.cs+++ b/Emby.Server.Implementations/Dto/DtoService.cs@@ -5,8 +5,6 @@ using System.Linq;using System.Threading.Tasks;using MediaBrowser.Common;using MediaBrowser.Controller.Channels;-using MediaBrowser.Controller.Configuration;-using MediaBrowser.Controller.Devices;using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;@@ -21,8 +19,6 @@ using MediaBrowser.Controller.Providers;using MediaBrowser.Model.Drawing;using MediaBrowser.Model.Dto;using MediaBrowser.Model.Entities;-using MediaBrowser.Model.Extensions;-using MediaBrowser.Model.IO;using MediaBrowser.Model.Querying;using Microsoft.Extensions.Logging;@@ -83,15 +79,8 @@ namespace Emby.Server.Implementations.Dtoreturn GetBaseItemDto(item, options, user, owner);}- public BaseItemDto[] GetBaseItemDtos(List<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)- {- return GetBaseItemDtos(items, items.Count, options, user, owner);- }-- public BaseItemDto[] GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null)- {- return GetBaseItemDtos(items, items.Length, options, user, owner);- }+ public BaseItemDto[] GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null)+ => GetBaseItemDtos(items, items.Count, options, user, owner);public BaseItemDto[] GetBaseItemDtos(IEnumerable<BaseItem> items, int itemCount, DtoOptions options, User user = null, BaseItem owner = null){diff --git a/Emby.Server.Implementations/Session/SessionManager.cs b/Emby.Server.Implementations/Session/SessionManager.csindex fa0ab62d32..03e7b26545 100644--- a/Emby.Server.Implementations/Session/SessionManager.cs+++ b/Emby.Server.Implementations/Session/SessionManager.cs@@ -1090,7 +1090,7 @@ namespace Emby.Server.Implementations.Sessionawait SendMessageToSession(session, "Play", command, cancellationToken).ConfigureAwait(false);}- private IList<BaseItem> TranslateItemForPlayback(Guid id, User user)+ private IEnumerable<BaseItem> TranslateItemForPlayback(Guid id, User user){var item = _libraryManager.GetItemById(id);diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.csindex a037357ede..69673a49c1 100644--- a/MediaBrowser.Api/BaseApiService.cs+++ b/MediaBrowser.Api/BaseApiService.cs@@ -172,16 +172,9 @@ namespace MediaBrowser.Apiif (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes)){- if (string.IsNullOrEmpty(hasDtoOptions.EnableImageTypes))- {- options.ImageTypes = Array.Empty<ImageType>();- }- else- {- options.ImageTypes = hasDtoOptions.EnableImageTypes.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries)- .Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true))- .ToArray();- }+ options.ImageTypes = hasDtoOptions.EnableImageTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)+ .Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true))+ .ToArray();}}diff --git a/MediaBrowser.Api/FilterService.cs b/MediaBrowser.Api/FilterService.csindex 9caf07cea2..201efe7371 100644--- a/MediaBrowser.Api/FilterService.cs+++ b/MediaBrowser.Api/FilterService.cs@@ -1,4 +1,5 @@using System;+using System.Collections.Generic;using System.Linq;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Library;@@ -180,7 +181,7 @@ namespace MediaBrowser.Apireturn ToOptimizedResult(filters);}- private QueryFiltersLegacy GetFilters(BaseItem[] items)+ private QueryFiltersLegacy GetFilters(IReadOnlyCollection<BaseItem> items){var result = new QueryFiltersLegacy();diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.csindex 84475467fe..3c7ad1d0a6 100644--- a/MediaBrowser.Api/UserLibrary/ItemsService.cs+++ b/MediaBrowser.Api/UserLibrary/ItemsService.cs@@ -1,5 +1,6 @@using System;using System.Collections.Generic;+using System.Diagnostics;using System.Globalization;using System.Linq;using MediaBrowser.Controller.Dto;@@ -197,29 +198,27 @@ namespace MediaBrowser.Api.UserLibraryrequest.ParentId = null;}- var item = string.IsNullOrEmpty(request.ParentId) ?- null :- _libraryManager.GetItemById(request.ParentId);+ BaseItem item = null;- if (item == null)+ if (!string.IsNullOrEmpty(request.ParentId)){- item = string.IsNullOrEmpty(request.ParentId) ?- user == null ? _libraryManager.RootFolder : _libraryManager.GetUserRootFolder() :- _libraryManager.GetItemById(request.ParentId);+ item = _libraryManager.GetItemById(request.ParentId);}- // Default list type = children+ if (item == null)+ {+ item = _libraryManager.GetUserRootFolder();+ }- var folder = item as Folder;+ Folder folder = item as Folder;if (folder == null){- folder = user == null ? _libraryManager.RootFolder : _libraryManager.GetUserRootFolder();+ folder = _libraryManager.GetUserRootFolder();}var hasCollectionType = folder as IHasCollectionType;- var isPlaylistQuery = (hasCollectionType != null && string.Equals(hasCollectionType.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase));-- if (isPlaylistQuery)+ if (hasCollectionType != null+ && string.Equals(hasCollectionType.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase)){request.Recursive = true;request.IncludeItemTypes = "Playlist";@@ -235,20 +234,12 @@ namespace MediaBrowser.Api.UserLibrary};}- if (request.Recursive || !string.IsNullOrEmpty(request.Ids) || user == null)- {- return folder.GetItems(GetItemsQuery(request, dtoOptions, user));- }-- var userRoot = item as UserRootFolder;-- if (userRoot == null)+ if (request.Recursive || !string.IsNullOrEmpty(request.Ids) || !(item is UserRootFolder)){return folder.GetItems(GetItemsQuery(request, dtoOptions, user));}var itemsArray = folder.GetChildren(user, true).ToArray();-return new QueryResult<BaseItem>{Items = itemsArray,diff --git a/MediaBrowser.Controller/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.csindex aa99f6b58f..cdaf95f5ce 100644--- a/MediaBrowser.Controller/Dto/DtoOptions.cs+++ b/MediaBrowser.Controller/Dto/DtoOptions.cs@@ -36,9 +36,7 @@ namespace MediaBrowser.Controller.Dto.ToArray();public bool ContainsField(ItemFields field)- {- return AllItemFields.Contains(field);- }+ => Fields.Contains(field);public DtoOptions(bool allFields){@@ -47,15 +45,7 @@ namespace MediaBrowser.Controller.DtoEnableUserData = true;AddCurrentProgram = true;- if (allFields)- {- Fields = AllItemFields;- }- else- {- Fields = new ItemFields[] { };- }-+ Fields = allFields ? AllItemFields : Array.Empty<ItemFields>();ImageTypes = AllImageTypes;}diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.csindex df5ec5dd0b..4b6fd58fea 100644--- a/MediaBrowser.Controller/Dto/IDtoService.cs+++ b/MediaBrowser.Controller/Dto/IDtoService.cs@@ -57,9 +57,7 @@ namespace MediaBrowser.Controller.Dto/// <param name="options">The options.</param>/// <param name="user">The user.</param>/// <param name="owner">The owner.</param>- BaseItemDto[] GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null);-- BaseItemDto[] GetBaseItemDtos(List<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null);+ BaseItemDto[] GetBaseItemDtos(IReadOnlyList<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null);/// <summary>/// Gets the item by name dto.diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.csindex 8bfadbee6c..e49ff20baa 100644--- a/MediaBrowser.Controller/Entities/Folder.cs+++ b/MediaBrowser.Controller/Entities/Folder.cs@@ -810,37 +810,19 @@ namespace MediaBrowser.Controller.Entities{if (query.ItemIds.Length > 0){- var result = LibraryManager.GetItemsResult(query);-- if (query.OrderBy.Length == 0)- {- var ids = query.ItemIds.ToList();-- // Try to preserve order- result.Items = result.Items.OrderBy(i => ids.IndexOf(i.Id)).ToArray();- }- return result;+ return LibraryManager.GetItemsResult(query);}return GetItemsInternal(query);}- public BaseItem[] GetItemList(InternalItemsQuery query)+ public IReadOnlyList<BaseItem> GetItemList(InternalItemsQuery query){query.EnableTotalRecordCount = false;if (query.ItemIds.Length > 0){- var result = LibraryManager.GetItemList(query);-- if (query.OrderBy.Length == 0)- {- var ids = query.ItemIds.ToList();-- // Try to preserve order- return result.OrderBy(i => ids.IndexOf(i.Id)).ToArray();- }- return result.ToArray();+ return LibraryManager.GetItemList(query);}return GetItemsInternal(query).Items;