Merge pull request #313 from Mbucari/master

Fixed hidden items being duplicated on library scan
This commit is contained in:
rmcrackan 2022-07-18 15:08:04 -04:00 committed by GitHub
commit decf75411f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -45,9 +45,13 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
#region Items Management #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) public void ReplaceList(IEnumerable<GridEntry> newItems)
{ {
Items.Clear(); Items.Clear();
FilterRemoved.Clear();
((List<GridEntry>)Items).AddRange(newItems); ((List<GridEntry>)Items).AddRange(newItems);
ResetCollection(); ResetCollection();
} }

View File

@ -113,20 +113,20 @@ namespace LibationWinForms.AvaloniaUI.ViewModels
await Dispatcher.UIThread.InvokeAsync(() => await Dispatcher.UIThread.InvokeAsync(() =>
{ {
GridEntries.ReplaceList(newEntries); 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; GridEntries.Filter = existingFilter;
ReSort(); 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) catch (Exception ex)
{ {