Fixed hidden items being duplicated on library scan
This commit is contained in:
parent
720fd64c97
commit
10359aa5e8
@ -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();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user