| | 1 | | #nullable disable |
| | 2 | | #pragma warning disable CS1591 |
| | 3 | |
|
| | 4 | | using Jellyfin.Data.Enums; |
| | 5 | | using Jellyfin.Database.Implementations.Entities; |
| | 6 | | using MediaBrowser.Controller.Entities; |
| | 7 | | using MediaBrowser.Controller.Library; |
| | 8 | | using MediaBrowser.Controller.Sorting; |
| | 9 | | using MediaBrowser.Model.Querying; |
| | 10 | |
|
| | 11 | | namespace Emby.Server.Implementations.Sorting |
| | 12 | | { |
| | 13 | | public class IsFavoriteOrLikeComparer : IUserBaseItemComparer |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Gets or sets the user. |
| | 17 | | /// </summary> |
| | 18 | | /// <value>The user.</value> |
| | 19 | | public User User { get; set; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// Gets the name. |
| | 23 | | /// </summary> |
| | 24 | | /// <value>The name.</value> |
| 1 | 25 | | public ItemSortBy Type => ItemSortBy.IsFavoriteOrLiked; |
| | 26 | |
|
| | 27 | | /// <summary> |
| | 28 | | /// Gets or sets the user data repository. |
| | 29 | | /// </summary> |
| | 30 | | /// <value>The user data repository.</value> |
| | 31 | | public IUserDataManager UserDataRepository { get; set; } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Gets or sets the user manager. |
| | 35 | | /// </summary> |
| | 36 | | /// <value>The user manager.</value> |
| | 37 | | public IUserManager UserManager { get; set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Compares the specified x. |
| | 41 | | /// </summary> |
| | 42 | | /// <param name="x">The x.</param> |
| | 43 | | /// <param name="y">The y.</param> |
| | 44 | | /// <returns>System.Int32.</returns> |
| | 45 | | public int Compare(BaseItem x, BaseItem y) |
| | 46 | | { |
| 0 | 47 | | return GetValue(x).CompareTo(GetValue(y)); |
| | 48 | | } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Gets the date. |
| | 52 | | /// </summary> |
| | 53 | | /// <param name="x">The x.</param> |
| | 54 | | /// <returns>DateTime.</returns> |
| | 55 | | private int GetValue(BaseItem x) |
| | 56 | | { |
| 0 | 57 | | return x.IsFavoriteOrLiked(User) ? 0 : 1; |
| | 58 | | } |
| | 59 | | } |
| | 60 | | } |