From ecafd47f81b5add501be4516e1b7c270e8756342 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 8 Jul 2023 13:20:31 +0800 Subject: [PATCH] Fix sorting that causes crash --- TVRename/Forms/UI.cs | 2 +- TVRename/Utility/Sorters/ActionItemSorter.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TVRename/Forms/UI.cs b/TVRename/Forms/UI.cs index f214d8e3..919baaa0 100644 --- a/TVRename/Forms/UI.cs +++ b/TVRename/Forms/UI.cs @@ -4955,7 +4955,7 @@ private void tbJackettSearch_Click(object sender, EventArgs e) { JackettFinder.SearchForEpisode(i.Episode); } - else if (i is ShowSeasonMissing { Series: { }, SeasonNumberAsInt: { } } ssm) + else if (i is ShowSeasonMissing { Series: not null, SeasonNumberAsInt: not null } ssm) { JackettFinder.SearchForSeason(ssm.Series, ssm.SeasonNumberAsInt.Value); } diff --git a/TVRename/Utility/Sorters/ActionItemSorter.cs b/TVRename/Utility/Sorters/ActionItemSorter.cs index 8e986b3f..6bd24d19 100644 --- a/TVRename/Utility/Sorters/ActionItemSorter.cs +++ b/TVRename/Utility/Sorters/ActionItemSorter.cs @@ -123,9 +123,11 @@ public class ActionItemErrorsSorter : ActionItemStringSorter } public class ActionItemSeasonSorter : ActionItemSorter { - protected override int CompareItems(Item x, Item y) => x.SeasonNumberAsInt ?? 0 - y.SeasonNumberAsInt ?? 0; + protected override int CompareItems(Item x, Item y) => GetValue(x) - GetValue(y); + private static int GetValue(Item x) => x.SeasonNumberAsInt ?? 0; } public class ActionItemEpisodeSorter : ActionItemSorter { - protected override int CompareItems(Item x, Item y) => x.EpisodeNumber ?? 0 - y.EpisodeNumber ?? 0 ; + protected override int CompareItems(Item x, Item y) => GetValue(x) - GetValue(y); + private static int GetValue(Item x) => x.EpisodeNumber ?? 0; }