diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs index daa31e6e..f7a66be2 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/GridEntryCollection.cs @@ -45,9 +45,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels #region Items Management + /// + /// Removes all items from the collection, both visible and hidden, adds new items to the visible collection. + /// public void ReplaceList(IEnumerable newItems) { Items.Clear(); + FilterRemoved.Clear(); ((List)Items).AddRange(newItems); ResetCollection(); } diff --git a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs index f8b9fafd..c5f884af 100644 --- a/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs +++ b/Source/LibationWinForms/AvaloniaUI/ViewModels/ProductsDisplayViewModel.cs @@ -113,20 +113,20 @@ namespace LibationWinForms.AvaloniaUI.ViewModels await Dispatcher.UIThread.InvokeAsync(() => { GridEntries.ReplaceList(newEntries); + + //We're replacing the list, so preserve usere's existing collapse/expand + //state. When resetting a list, default state is open. + foreach (var series in existingSeriesEntries) + { + var sEntry = GridEntries.InternalList.FirstOrDefault(ge => ge.AudibleProductId == series.AudibleProductId); + if (sEntry is SeriesEntry se && !series.Liberate.Expanded) + GridEntries.CollapseItem(se); + } + GridEntries.Filter = existingFilter; ReSort(); + VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count()); }); - - //We're replacing the list, so preserve usere's existing collapse/expand - //state. When resetting a list, default state is open. - foreach (var series in existingSeriesEntries) - { - 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)); - } - - await Dispatcher.UIThread.InvokeAsync(() => VisibleCountChanged?.Invoke(this, GridEntries.BookEntries().Count())); } catch (Exception ex) {