Fix bug and add groundwork for future feature
This commit is contained in:
parent
0a6e55dcb7
commit
c95ba0764b
@ -133,6 +133,11 @@ namespace AudibleUtilities
|
||||
{
|
||||
//Get child episodes asynchronously and await all at the end
|
||||
getChildEpisodesTasks.Add(getChildEpisodesAsync(concurrencySemaphore, item));
|
||||
|
||||
//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.
|
||||
items.Add(item);
|
||||
}
|
||||
else if (!item.IsEpisodes)
|
||||
items.Add(item);
|
||||
@ -178,7 +183,7 @@ namespace AudibleUtilities
|
||||
// actual individual episode, not the parent of a series.
|
||||
// for now I'm keeping it inside this method since it fits the work flow, incl. importEpisodes logic
|
||||
if (!children.Any())
|
||||
return new List<Item>() { parent };
|
||||
return new();
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
|
||||
@ -109,5 +109,6 @@ namespace LibationWinForms.GridView
|
||||
=> gridEntries.Series().FirstOrDefault(i => matchSeries.Any(s => s.Series.Name == i.Series));
|
||||
public static IEnumerable<SeriesEntry> EmptySeries(this IEnumerable<GridEntry> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<GridEntry>().ToList();
|
||||
|
||||
var episodes = dbBooks.Where(b => b.Book.ContentType is ContentType.Episode).ToList();
|
||||
var episodes = dbBooks.Where(b => b.IsEpisodeWithSeries()).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.Book.ContentType is ContentType.Episode)
|
||||
if (libraryBook.IsEpisodeWithSeries())
|
||||
{
|
||||
LibraryBookEntry lbe;
|
||||
//Find the series that libraryBook belongs to, if it exists
|
||||
@ -148,7 +148,7 @@ namespace LibationWinForms.GridView
|
||||
|
||||
series.NotifyPropertyChanged();
|
||||
}
|
||||
else
|
||||
else if (libraryBook.Book.ContentType is not ContentType.Episode)
|
||||
//Add the new product
|
||||
bindingList.Insert(0, new LibraryBookEntry(libraryBook));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user