Suppress VisibleCountChanged firing when updating grid
This commit is contained in:
parent
56de1e7659
commit
2725340994
@ -5,6 +5,7 @@ using Avalonia.Threading;
|
|||||||
using DataLayer;
|
using DataLayer;
|
||||||
using LibationAvalonia.Dialogs.Login;
|
using LibationAvalonia.Dialogs.Login;
|
||||||
using LibationUiBase.GridView;
|
using LibationUiBase.GridView;
|
||||||
|
using NPOI.SS.Formula.Functions;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -116,17 +117,20 @@ namespace LibationAvalonia.ViewModels
|
|||||||
//Create the filtered-in list before adding entries to avoid a refresh
|
//Create the filtered-in list before adding entries to avoid a refresh
|
||||||
FilteredInGridEntries = QueryResults(geList, FilterString);
|
FilteredInGridEntries = QueryResults(geList, FilterString);
|
||||||
SOURCE.AddRange(geList.OrderByDescending(e => e.DateAdded));
|
SOURCE.AddRange(geList.OrderByDescending(e => e.DateAdded));
|
||||||
GridEntries.CollectionChanged += (_, _)
|
GridEntries.CollectionChanged += GridEntries_CollectionChanged;
|
||||||
=> VisibleCountChanged?.Invoke(this, GridEntries.OfType<ILibraryBookEntry>().Count());
|
GridEntries_CollectionChanged();
|
||||||
|
|
||||||
VisibleCountChanged?.Invoke(this, GridEntries.OfType<ILibraryBookEntry>().Count());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GridEntries_CollectionChanged(object sender = null, EventArgs e = null)
|
||||||
|
=> VisibleCountChanged?.Invoke(this, GridEntries.OfType<ILibraryBookEntry>().Count());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call when there's been a change to the library
|
/// Call when there's been a change to the library
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task UpdateGridAsync(List<LibraryBook> dbBooks)
|
internal async Task UpdateGridAsync(List<LibraryBook> dbBooks)
|
||||||
{
|
{
|
||||||
|
GridEntries.CollectionChanged -= GridEntries_CollectionChanged;
|
||||||
|
|
||||||
#region Add new or update existing grid entries
|
#region Add new or update existing grid entries
|
||||||
|
|
||||||
//Add absent entries to grid, or update existing entry
|
//Add absent entries to grid, or update existing entry
|
||||||
@ -176,6 +180,9 @@ namespace LibationAvalonia.ViewModels
|
|||||||
|
|
||||||
await Filter(FilterString);
|
await Filter(FilterString);
|
||||||
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
|
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
|
||||||
|
|
||||||
|
GridEntries.CollectionChanged += GridEntries_CollectionChanged;
|
||||||
|
GridEntries_CollectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveBooks(IEnumerable<ILibraryBookEntry> removedBooks, IEnumerable<ISeriesEntry> removedSeries)
|
private void RemoveBooks(IEnumerable<ILibraryBookEntry> removedBooks, IEnumerable<ISeriesEntry> removedSeries)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user