support parent item images for unattached items

This commit is contained in:
Luke Pulverenti 2013-07-30 10:51:28 -04:00
parent 82352d13e4
commit 88f1723f99
5 changed files with 29 additions and 16 deletions

View File

@ -396,7 +396,7 @@ namespace MediaBrowser.Api
var tasks = item.ThemeSongIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user));
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));
var items = await Task.WhenAll(tasks).ConfigureAwait(false);
@ -445,7 +445,7 @@ namespace MediaBrowser.Api
var tasks = item.ThemeVideoIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user));
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));
var items = await Task.WhenAll(tasks).ConfigureAwait(false);

View File

@ -399,7 +399,12 @@ namespace MediaBrowser.Api.UserLibrary
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var items = movie.SpecialFeatureIds.Select(_itemRepo.RetrieveItem).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToList();
var items = movie.SpecialFeatureIds
.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, movie))
.Select(t => t.Result)
.ToList();
return ToOptimizedResult(items);
}
@ -420,7 +425,12 @@ namespace MediaBrowser.Api.UserLibrary
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var items = item.LocalTrailerIds.Select(_itemRepo.RetrieveItem).OrderBy(i => i.SortName).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToList();
var items = item.LocalTrailerIds
.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item))
.Select(t => t.Result)
.ToList();
return ToOptimizedResult(items);
}

View File

@ -66,7 +66,7 @@ namespace MediaBrowser.Api
var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user))
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, video))
.Select(t => t.Result)
.ToArray();

View File

@ -310,7 +310,6 @@ namespace MediaBrowser.Common.Implementations.Updates
protected IEnumerable<PackageVersionInfo> FilterCatalog(IEnumerable<PackageInfo> catalog, bool withAutoUpdateEnabled)
{
var plugins = ApplicationHost.Plugins;
if (withAutoUpdateEnabled)

View File

@ -47,9 +47,10 @@ namespace MediaBrowser.Controller.Dto
/// <param name="item">The item.</param>
/// <param name="fields">The fields.</param>
/// <param name="user">The user.</param>
/// <param name="owner">The owner.</param>
/// <returns>Task{DtoBaseItem}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public async Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null)
public async Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null)
{
if (item == null)
{
@ -93,7 +94,7 @@ namespace MediaBrowser.Controller.Dto
AttachUserSpecificInfo(dto, item, user, fields);
}
AttachBasicFields(dto, item, fields);
AttachBasicFields(dto, item, owner, fields);
if (fields.Contains(ItemFields.SoundtrackIds))
{
@ -378,8 +379,9 @@ namespace MediaBrowser.Controller.Dto
/// </summary>
/// <param name="dto">The dto.</param>
/// <param name="item">The item.</param>
/// <param name="owner">The owner.</param>
/// <param name="fields">The fields.</param>
private void AttachBasicFields(BaseItemDto dto, BaseItem item, List<ItemFields> fields)
private void AttachBasicFields(BaseItemDto dto, BaseItem item, BaseItem owner, List<ItemFields> fields)
{
if (fields.Contains(ItemFields.DateCreated))
{
@ -495,7 +497,7 @@ namespace MediaBrowser.Controller.Dto
// If there are no backdrops, indicate what parent has them in case the Ui wants to allow inheritance
if (dto.BackdropImageTags.Count == 0)
{
var parentWithBackdrop = GetParentBackdropItem(item);
var parentWithBackdrop = GetParentBackdropItem(item, owner);
if (parentWithBackdrop != null)
{
@ -514,7 +516,7 @@ namespace MediaBrowser.Controller.Dto
// If there is no logo, indicate what parent has one in case the Ui wants to allow inheritance
if (!dto.HasLogo)
{
var parentWithLogo = GetParentImageItem(item, ImageType.Logo);
var parentWithLogo = GetParentImageItem(item, ImageType.Logo, owner);
if (parentWithLogo != null)
{
@ -527,7 +529,7 @@ namespace MediaBrowser.Controller.Dto
// If there is no art, indicate what parent has one in case the Ui wants to allow inheritance
if (!dto.HasArtImage)
{
var parentWithImage = GetParentImageItem(item, ImageType.Art);
var parentWithImage = GetParentImageItem(item, ImageType.Art, owner);
if (parentWithImage != null)
{
@ -936,10 +938,11 @@ namespace MediaBrowser.Controller.Dto
/// If an item does not any backdrops, this can be used to find the first parent that does have one
/// </summary>
/// <param name="item">The item.</param>
/// <param name="owner">The owner.</param>
/// <returns>BaseItem.</returns>
private BaseItem GetParentBackdropItem(BaseItem item)
private BaseItem GetParentBackdropItem(BaseItem item, BaseItem owner)
{
var parent = item.Parent;
var parent = item.Parent ?? owner;
while (parent != null)
{
@ -959,10 +962,11 @@ namespace MediaBrowser.Controller.Dto
/// </summary>
/// <param name="item">The item.</param>
/// <param name="type">The type.</param>
/// <param name="owner">The owner.</param>
/// <returns>BaseItem.</returns>
private BaseItem GetParentImageItem(BaseItem item, ImageType type)
private BaseItem GetParentImageItem(BaseItem item, ImageType type, BaseItem owner)
{
var parent = item.Parent;
var parent = item.Parent ?? owner;
while (parent != null)
{