| | | 1 | | #nullable disable |
| | | 2 | | |
| | | 3 | | #pragma warning disable CS1591 |
| | | 4 | | |
| | | 5 | | using Jellyfin.Data.Enums; |
| | | 6 | | using Jellyfin.Database.Implementations.Entities; |
| | | 7 | | using MediaBrowser.Controller.Entities; |
| | | 8 | | using MediaBrowser.Controller.Library; |
| | | 9 | | using MediaBrowser.Controller.Sorting; |
| | | 10 | | |
| | | 11 | | namespace Emby.Server.Implementations.Sorting |
| | | 12 | | { |
| | | 13 | | public class IsPlayedComparer : 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.IsUnplayed; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets or sets the user data manager. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <value>The user data manager.</value> |
| | | 31 | | public IUserDataManager UserDataManager { 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.IsPlayed(User, userItemData: null) ? 0 : 1; |
| | | 58 | | } |
| | | 59 | | } |
| | | 60 | | } |