aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Api/UserLibrary/ItemsService.cs
diff options
context:
space:
mode:
authorVasily <JustAMan@users.noreply.github.com>2019-02-27 17:29:12 +0300
committerGitHub <noreply@github.com>2019-02-27 17:29:12 +0300
commit8c2af50170ea2a7964a6ad40bbe60026cfa625b0 (patch)
tree8cf813cc47dbc9c9fcc661fa0ba732022860a89b /MediaBrowser.Api/UserLibrary/ItemsService.cs
parent9651a78b0c42958f01b01aee78e661125ad1970d (diff)
parent1731bf7372a13ea8c656eb9f895508b7b4c66784 (diff)
Merge pull request #1011 from Bond-009/order
Don't try to order the response the same as the request
Diffstat (limited to 'MediaBrowser.Api/UserLibrary/ItemsService.cs')
-rw-r--r--MediaBrowser.Api/UserLibrary/ItemsService.cs35
1 files changed, 13 insertions, 22 deletions
diff --git a/MediaBrowser.Api/UserLibrary/ItemsService.cs b/MediaBrowser.Api/UserLibrary/ItemsService.cs
index 84475467f..3c7ad1d0a 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.UserLibrary
request.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,