Use GetParentItem where applicable

This commit is contained in:
crobibero 2020-12-01 16:16:17 -07:00
parent f48e47be5f
commit b5a7a74e89
4 changed files with 8 additions and 34 deletions

View File

@ -2462,19 +2462,14 @@ namespace Emby.Server.Implementations.Library
public BaseItem GetParentItem(string parentId, Guid? userId)
{
if (!string.IsNullOrEmpty(parentId))
if (string.IsNullOrEmpty(parentId))
{
return GetItemById(new Guid(parentId));
return GetParentItem((Guid?)null, userId);
}
if (userId.HasValue && userId != Guid.Empty)
{
return GetUserRootFolder();
}
return RootFolder;
return GetParentItem(new Guid(parentId), userId);
}
public BaseItem GetParentItem(Guid? parentId, Guid? userId)
{
if (parentId.HasValue)

View File

@ -118,16 +118,11 @@ namespace Jellyfin.Api.Controllers
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
User? user = null;
BaseItem parentItem;
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
if (userId.HasValue && !userId.Equals(Guid.Empty))
{
user = _userManager.GetUserById(userId.Value);
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.GetUserRootFolder();
}
else
{
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.RootFolder;
}
var query = new InternalItemsQuery(user)
@ -322,16 +317,11 @@ namespace Jellyfin.Api.Controllers
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
User? user = null;
BaseItem parentItem;
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
if (userId.HasValue && !userId.Equals(Guid.Empty))
{
user = _userManager.GetUserById(userId.Value);
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.GetUserRootFolder();
}
else
{
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.RootFolder;
}
var query = new InternalItemsQuery(user)

View File

@ -239,14 +239,8 @@ namespace Jellyfin.Api.Controllers
parentId = null;
}
BaseItem? item = null;
var item = _libraryManager.GetParentItem(parentId, userId);
QueryResult<BaseItem> result;
if (parentId.HasValue)
{
item = _libraryManager.GetItemById(parentId.Value);
}
item ??= _libraryManager.GetUserRootFolder();
if (!(item is Folder folder))
{

View File

@ -89,16 +89,11 @@ namespace Jellyfin.Api.Controllers
.AddAdditionalDtoOptions(enableImages, enableUserData, imageTypeLimit, enableImageTypes);
User? user = null;
BaseItem parentItem;
BaseItem parentItem = _libraryManager.GetParentItem(parentId, userId);
if (userId.HasValue && !userId.Equals(Guid.Empty))
{
user = _userManager.GetUserById(userId.Value);
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.GetUserRootFolder();
}
else
{
parentItem = parentId.HasValue ? _libraryManager.GetItemById(parentId.Value) : _libraryManager.RootFolder;
}
IList<BaseItem> items;