aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/FilterController.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-12-02 07:11:42 -0700
committercrobibero <cody@robibe.ro>2020-12-02 07:11:42 -0700
commit09b1e571f4e4dad19495e8873a5bc712a3bf9b7c (patch)
tree921210f9f19f73b4f1ff77e062d56233180d126c /Jellyfin.Api/Controllers/FilterController.cs
parentb5a7a74e897539a4f5389faca93bdfe5bfd5b4d5 (diff)
Apply suggestions from review
Diffstat (limited to 'Jellyfin.Api/Controllers/FilterController.cs')
-rw-r--r--Jellyfin.Api/Controllers/FilterController.cs40
1 files changed, 12 insertions, 28 deletions
diff --git a/Jellyfin.Api/Controllers/FilterController.cs b/Jellyfin.Api/Controllers/FilterController.cs
index 521960ae6..1c0f1c1df 100644
--- a/Jellyfin.Api/Controllers/FilterController.cs
+++ b/Jellyfin.Api/Controllers/FilterController.cs
@@ -54,35 +54,18 @@ namespace Jellyfin.Api.Controllers
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] includeItemTypes,
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] mediaTypes)
{
- var parentItem = parentId.HasValue
- ? _libraryManager.GetItemById(parentId.Value)
- : null;
-
var user = userId.HasValue && !userId.Equals(Guid.Empty)
? _userManager.GetUserById(userId.Value)
: null;
- if (includeItemTypes.Length == 1
- && (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
- || string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
- || string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase)
- || string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase)))
- {
- parentItem = null;
- }
-
- BaseItem? item;
- if (parentId.HasValue)
- {
- item = parentItem;
- }
- else if (user == null)
- {
- item = _libraryManager.RootFolder;
- }
- else
+ BaseItem? item = null;
+ if (includeItemTypes.Length != 1
+ || !(string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
+ || string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
+ || string.Equals(includeItemTypes[0], nameof(Trailer), StringComparison.OrdinalIgnoreCase)
+ || string.Equals(includeItemTypes[0], "Program", StringComparison.OrdinalIgnoreCase)))
{
- item = _libraryManager.GetUserRootFolder();
+ item = _libraryManager.GetParentItem(parentId, user?.Id);
}
var query = new InternalItemsQuery
@@ -158,14 +141,11 @@ namespace Jellyfin.Api.Controllers
[FromQuery] bool? isSeries,
[FromQuery] bool? recursive)
{
- var parentItem = parentId.HasValue
- ? _libraryManager.GetItemById(parentId.Value)
- : null;
-
var user = userId.HasValue && !userId.Equals(Guid.Empty)
? _userManager.GetUserById(userId.Value)
: null;
+ BaseItem? parentItem = null;
if (includeItemTypes.Length == 1
&& (string.Equals(includeItemTypes[0], nameof(BoxSet), StringComparison.OrdinalIgnoreCase)
|| string.Equals(includeItemTypes[0], nameof(Playlist), StringComparison.OrdinalIgnoreCase)
@@ -174,6 +154,10 @@ namespace Jellyfin.Api.Controllers
{
parentItem = null;
}
+ else if (parentId.HasValue)
+ {
+ parentItem = _libraryManager.GetItemById(parentId.Value);
+ }
var filters = new QueryFilters();
var genreQuery = new InternalItemsQuery(user)