diff options
| author | Bond-009 <bond.009@outlook.com> | 2024-03-28 17:19:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-28 17:19:59 +0100 |
| commit | d6355261e32fac639fd81bc1041bc0e50f1705e4 (patch) | |
| tree | d03ada68730c1f7addcafcab0a8274c0d09ea131 /Emby.Server.Implementations/Sorting | |
| parent | 5db0c5a0e45938b465e972d8ffcd476b7ea2d460 (diff) | |
| parent | 71fc475bb39e0439af7b9c6e5289490ea20fad29 (diff) | |
Merge pull request #9641 from Daaiid/fix_compiler_warnings
Fix compiler warnings for Emby.Server.Implementations
Diffstat (limited to 'Emby.Server.Implementations/Sorting')
| -rw-r--r-- | Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs index 65c8599e7..59185cdb7 100644 --- a/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/AlbumArtistComparer.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using Jellyfin.Data.Enums; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.Audio; @@ -9,37 +8,35 @@ using MediaBrowser.Model.Querying; namespace Emby.Server.Implementations.Sorting { /// <summary> - /// Class AlbumArtistComparer. + /// Allows comparing artists of albums. Only the first artist of each album is considered. /// </summary> public class AlbumArtistComparer : IBaseItemComparer { /// <summary> - /// Gets the name. + /// Gets the item type this comparer compares. /// </summary> - /// <value>The name.</value> public ItemSortBy Type => ItemSortBy.AlbumArtist; /// <summary> - /// Compares the specified x. + /// Compares the specified arguments on their primary artist. /// </summary> - /// <param name="x">The x.</param> - /// <param name="y">The y.</param> - /// <returns>System.Int32.</returns> + /// <param name="x">First item to compare.</param> + /// <param name="y">Second item to compare.</param> + /// <returns>Zero if equal, else negative or positive number to indicate order.</returns> public int Compare(BaseItem? x, BaseItem? y) { - return string.Compare(GetValue(x), GetValue(y), StringComparison.OrdinalIgnoreCase); + return string.Compare(GetFirstAlbumArtist(x), GetFirstAlbumArtist(y), StringComparison.OrdinalIgnoreCase); } - /// <summary> - /// Gets the value. - /// </summary> - /// <param name="x">The x.</param> - /// <returns>System.String.</returns> - private static string? GetValue(BaseItem? x) + private static string? GetFirstAlbumArtist(BaseItem? x) { - var audio = x as IHasAlbumArtist; + if (x is IHasAlbumArtist audio + && audio.AlbumArtists.Count != 0) + { + return audio.AlbumArtists[0]; + } - return audio?.AlbumArtists.FirstOrDefault(); + return null; } } } |
