From 2b5f3f294ed7b3660c0a5898d0ece42a7d7cca72 Mon Sep 17 00:00:00 2001 From: ankenyr Date: Sun, 12 Sep 2021 15:05:37 -0700 Subject: Fixing #6269 by comparing PremiereDate when episode comparison would otherwise be equal. --- .../Sorting/AiredEpisodeOrderComparer.cs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 2b0ab536f..821fa9778 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -28,16 +28,6 @@ namespace Emby.Server.Implementations.Sorting throw new ArgumentNullException(nameof(y)); } - if (x.PremiereDate.HasValue && y.PremiereDate.HasValue) - { - var val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); - - if (val != 0) - { - // return val; - } - } - var episode1 = x as Episode; var episode2 = y as Episode; @@ -156,8 +146,16 @@ namespace Emby.Server.Implementations.Sorting { var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1); var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1); + var compare_val = xValue.CompareTo(yValue); + if (compare_val == 0) + { + if (x.PremiereDate.HasValue & y.PremiereDate.HasValue) + { + compare_val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); + } + } - return xValue.CompareTo(yValue); + return compare_val; } /// -- cgit v1.2.3 From 96bc24b1dccb7b1f5467659b0350afa74afde243 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 13 Sep 2021 08:32:12 -0700 Subject: Update Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs Co-authored-by: Claus Vium --- Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 821fa9778..12e9c9b78 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -146,12 +146,11 @@ namespace Emby.Server.Implementations.Sorting { var xValue = ((x.ParentIndexNumber ?? -1) * 1000) + (x.IndexNumber ?? -1); var yValue = ((y.ParentIndexNumber ?? -1) * 1000) + (y.IndexNumber ?? -1); - var compare_val = xValue.CompareTo(yValue); - if (compare_val == 0) + var comparisonResult = xValue.CompareTo(yValue); + // If equal, compare premiere dates + if (comparisonResult == 0 && x.PremiereDate.HasValue && y.PremiereDate.HasValue) { - if (x.PremiereDate.HasValue & y.PremiereDate.HasValue) - { - compare_val = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); + comparisonResult = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); } } -- cgit v1.2.3 From 8d45656c51c684fbbf3e94319ac5ec050d5e44b4 Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 13 Sep 2021 08:32:18 -0700 Subject: Update Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs Co-authored-by: Claus Vium --- Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 12e9c9b78..fd422ffbf 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -154,7 +154,7 @@ namespace Emby.Server.Implementations.Sorting } } - return compare_val; + return comparisonResult; } /// -- cgit v1.2.3 From d557a5371e63c46c62c62f3c9e0bae1bed0d820c Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 13 Sep 2021 08:32:28 -0700 Subject: Update Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs Co-authored-by: Claus Vium --- Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index fd422ffbf..037eb170a 100644 --- a/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/Emby.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -151,7 +151,6 @@ namespace Emby.Server.Implementations.Sorting if (comparisonResult == 0 && x.PremiereDate.HasValue && y.PremiereDate.HasValue) { comparisonResult = DateTime.Compare(x.PremiereDate.Value, y.PremiereDate.Value); - } } return comparisonResult; -- cgit v1.2.3