Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds sorting by premier dates to the /Items/Latest api endpoint #11512

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Emby.Server.Implementations/Library/UserViewManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ private IReadOnlyList<BaseItem> GetItemsForLatestItems(User user, LatestItemsQue
IncludeItemTypes = includeItemTypes,
OrderBy = new[]
{
(ItemSortBy.DateCreated, SortOrder.Descending),
(request.SortBy, SortOrder.Descending),
(ItemSortBy.SortName, SortOrder.Descending),
(ItemSortBy.ProductionYear, SortOrder.Descending)
},
Expand Down
1 change: 1 addition & 0 deletions Jellyfin.Api/Controllers/DisplayPreferencesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public DisplayPreferencesController(IDisplayPreferencesManager displayPreference
HomeSectionType.LiveTv,
HomeSectionType.NextUp,
HomeSectionType.LatestMedia,
HomeSectionType.LatestPremier,
HomeSectionType.None,
};

Expand Down
5 changes: 4 additions & 1 deletion Jellyfin.Api/Controllers/UserLibraryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ public ActionResult<BaseItemDto> GetRootFolder([FromQuery] Guid? userId)
/// <param name="enableUserData">Optional. include user data.</param>
/// <param name="limit">Return item limit.</param>
/// <param name="groupItems">Whether or not to group items into a parent container.</param>
/// <param name="sortByDateAdded">Whether or not to sort by date added or by premier date.</param>
/// <response code="200">Latest media returned.</response>
/// <returns>An <see cref="OkResult"/> containing the latest media.</returns>
[HttpGet("Items/Latest")]
Expand All @@ -531,7 +532,8 @@ public ActionResult<BaseItemDto> GetRootFolder([FromQuery] Guid? userId)
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] ImageType[] enableImageTypes,
[FromQuery] bool? enableUserData,
[FromQuery] int limit = 20,
[FromQuery] bool groupItems = true)
[FromQuery] bool groupItems = true,
[FromQuery] bool sortByDateAdded = true)
{
var requestUserId = RequestHelpers.GetUserId(User, userId);
var user = _userManager.GetUserById(requestUserId);
Expand Down Expand Up @@ -561,6 +563,7 @@ public ActionResult<BaseItemDto> GetRootFolder([FromQuery] Guid? userId)
Limit = limit,
ParentId = parentId ?? Guid.Empty,
UserId = requestUserId,
SortBy = sortByDateAdded ? ItemSortBy.DateCreated : ItemSortBy.PremiereDate
},
dtoOptions);

Expand Down
9 changes: 7 additions & 2 deletions Jellyfin.Data/Enums/HomeSectionType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Jellyfin.Data.Enums
namespace Jellyfin.Data.Enums
{
/// <summary>
/// An enum representing the different options for the home screen sections.
Expand Down Expand Up @@ -53,6 +53,11 @@ public enum HomeSectionType
/// <summary>
/// Continue Reading.
/// </summary>
ResumeBook = 9
ResumeBook = 9,

/// <summary>
/// Latest Premier.
/// </summary>
LatestPremier = 10
}
scampower3 marked this conversation as resolved.
Show resolved Hide resolved
}
6 changes: 6 additions & 0 deletions MediaBrowser.Model/Querying/LatestItemsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,11 @@ public LatestItemsQuery()
/// </summary>
/// <value>The enable image types.</value>
public ImageType[] EnableImageTypes { get; set; }

/// <summary>
/// Gets or sets sorting method.
/// </summary>
/// <value>ItemSortBy types.</value>
public ItemSortBy SortBy { get; set; }
}
}
Loading