From 1b2ec6772603f1279a983171adc848d50039585b Mon Sep 17 00:00:00 2001 From: Michael Bucari-Tovo Date: Thu, 26 May 2022 16:43:56 -0600 Subject: [PATCH] Add series info for parent will null order. --- Source/AudibleUtilities/ApiExtended.cs | 1 + Source/LibationWinForms/GridView/GridEntry.cs | 3 ++- Source/LibationWinForms/GridView/ProductsGrid.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/AudibleUtilities/ApiExtended.cs b/Source/AudibleUtilities/ApiExtended.cs index ca09a64b..9a8bf20c 100644 --- a/Source/AudibleUtilities/ApiExtended.cs +++ b/Source/AudibleUtilities/ApiExtended.cs @@ -137,6 +137,7 @@ namespace AudibleUtilities //Add the parent to the library because it contains the series //description, series rating, and series cover art which differ //from the individual episodes' values. + item.Series = new Series[]{ new Series { Asin = item.Asin, Title = item.TitleWithSubtitle } }; items.Add(item); } else if (!item.IsEpisodes) diff --git a/Source/LibationWinForms/GridView/GridEntry.cs b/Source/LibationWinForms/GridView/GridEntry.cs index e6d479f2..5a330897 100644 --- a/Source/LibationWinForms/GridView/GridEntry.cs +++ b/Source/LibationWinForms/GridView/GridEntry.cs @@ -109,6 +109,7 @@ namespace LibationWinForms.GridView => gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series)); public static IEnumerable EmptySeries(this IEnumerable gridEntries) => gridEntries.Series().Where(i => i.Children.Count == 0); - public static bool IsEpisodeWithSeries(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any(); + public static bool IsEpisodeChild(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order is not null; + public static bool IsEpisodeParent(this LibraryBook lb) => lb.Book.ContentType == ContentType.Episode && lb.Book.SeriesLink is not null && lb.Book.SeriesLink.Any() && lb.Book.SeriesLink.First().Order is null; } } diff --git a/Source/LibationWinForms/GridView/ProductsGrid.cs b/Source/LibationWinForms/GridView/ProductsGrid.cs index f655bf74..3fa7d0d8 100644 --- a/Source/LibationWinForms/GridView/ProductsGrid.cs +++ b/Source/LibationWinForms/GridView/ProductsGrid.cs @@ -84,7 +84,7 @@ namespace LibationWinForms.GridView { var geList = dbBooks.Where(b => b.Book.ContentType is not ContentType.Episode).Select(b => new LibraryBookEntry(b)).Cast().ToList(); - var episodes = dbBooks.Where(b => b.IsEpisodeWithSeries()).ToList(); + var episodes = dbBooks.Where(b => b.IsEpisodeChild()).ToList(); foreach (var series in episodes.Select(lb => lb.Book.SeriesLink.First()).DistinctBy(s => s.Series)) { @@ -117,7 +117,7 @@ namespace LibationWinForms.GridView // add new to top if (existingItem is null) { - if (libraryBook.IsEpisodeWithSeries()) + if (libraryBook.IsEpisodeChild()) { LibraryBookEntry lbe; //Find the series that libraryBook belongs to, if it exists