Fixed hidden items being duplicated on library scan

This commit is contained in:
Michael Bucari-Tovo 2022-07-18 12:36:53 -06:00
parent 720fd64c97
commit 10359aa5e8
2 changed files with 15 additions and 11 deletions

View File

@ -45,9 +45,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
#region Items Management
/// <summary>
/// Removes all items from the collection, both visible and hidden, adds new items to the visible collection.
/// </summary>
public void ReplaceList(IEnumerable<GridEntry> newItems)
{
Items.Clear();
FilterRemoved.Clear();
((List<GridEntry>)Items).AddRange(newItems);
ResetCollection();
}

View File

@ -113,9 +113,6 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
await Dispatcher.UIThread.InvokeAsync(() =>
{
GridEntries.ReplaceList(newEntries);
GridEntries.Filter = existingFilter;
ReSort();
});
//We're replacing the list, so preserve usere's existing collapse/expand
//state. When resetting a list, default state is open.
@ -123,10 +120,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
{
var sEntry = GridEntries.InternalList.FirstOrDefault(ge => ge.AudibleProductId == series.AudibleProductId);
if (sEntry is SeriesEntry se && !series.Liberate.Expanded)
await Dispatcher.UIThread.InvokeAsync(() => GridEntries.CollapseItem(se));
GridEntries.CollapseItem(se);
}
await Dispatcher.UIThread.InvokeAsync(() => VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count()));
GridEntries.Filter = existingFilter;
ReSort();
VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count());
});
}
catch (Exception ex)
{