add landing screen settings

This commit is contained in:
Luke Pulverenti 2017-04-18 16:11:42 -04:00
parent 310f0e2811
commit 7147bec7d8
3 changed files with 17 additions and 56 deletions

View File

@ -31,17 +31,6 @@ namespace MediaBrowser.Api.UserLibrary
public string PresetViews { get; set; }
}
[Route("/Users/{UserId}/SpecialViewOptions", "GET")]
public class GetSpecialViewOptions : IReturn<List<SpecialViewOption>>
{
/// <summary>
/// Gets or sets the user id.
/// </summary>
/// <value>The user id.</value>
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string UserId { get; set; }
}
[Route("/Users/{UserId}/GroupingOptions", "GET")]
public class GetGroupingOptions : IReturn<List<SpecialViewOption>>
{
@ -114,29 +103,6 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(result);
}
public async Task<object> Get(GetSpecialViewOptions request)
{
var user = _userManager.GetUserById(request.UserId);
var views = user.RootFolder
.GetChildren(user, true)
.OfType<ICollectionFolder>()
.Where(IsEligibleForSpecialView)
.ToList();
var list = views
.Select(i => new SpecialViewOption
{
Name = i.Name,
Id = i.Id.ToString("N")
})
.OrderBy(i => i.Name)
.ToList();
return ToOptimizedResult(list);
}
public async Task<object> Get(GetGroupingOptions request)
{
var user = _userManager.GetUserById(request.UserId);
@ -159,11 +125,6 @@ namespace MediaBrowser.Api.UserLibrary
return ToOptimizedResult(list);
}
private bool IsEligibleForSpecialView(ICollectionFolder view)
{
return UserView.IsEligibleForEnhancedView(view.CollectionType);
}
}
class SpecialViewOption

View File

@ -761,22 +761,33 @@ namespace MediaBrowser.Controller.Entities
itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User));
}
var itemsArray = itemsList.ToArray();
var totalCount = itemsArray.Length;
IEnumerable<BaseItem> returnItems;
int totalCount = 0;
if (query.EnableTotalRecordCount)
{
var itemsArray = itemsList.ToArray();
totalCount = itemsArray.Length;
returnItems = itemsArray;
}
else
{
returnItems = itemsList;
}
if (limit.HasValue)
{
itemsArray = itemsArray.Skip(startIndex ?? 0).Take(limit.Value).ToArray();
returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value);
}
else if (startIndex.HasValue)
{
itemsArray = itemsArray.Skip(startIndex.Value).ToArray();
returnItems = returnItems.Skip(startIndex.Value);
}
return new QueryResult<BaseItem>
{
TotalRecordCount = totalCount,
Items = itemsArray
Items = returnItems.ToArray()
};
}
@ -1493,7 +1504,7 @@ namespace MediaBrowser.Controller.Entities
{
if (itemDto.RecursiveItemCount.Value > 0)
{
var unplayedPercentage = (unplayedCount/itemDto.RecursiveItemCount.Value)*100;
var unplayedPercentage = (unplayedCount / itemDto.RecursiveItemCount.Value) * 100;
dto.PlayedPercentage = 100 - unplayedPercentage;
dto.Played = dto.PlayedPercentage.Value >= 100;
}

View File

@ -153,17 +153,6 @@ namespace MediaBrowser.Controller.Entities
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
public static bool IsEligibleForEnhancedView(string viewType)
{
var types = new[]
{
CollectionType.Movies,
CollectionType.TvShows
};
return types.Contains(viewType ?? string.Empty, StringComparer.OrdinalIgnoreCase);
}
public static bool EnableOriginalFolder(string viewType)
{
var types = new[]