Fix hang on grid update

This commit is contained in:
Michael Bucari-Tovo 2022-05-24 13:16:44 -06:00
parent b37472a954
commit 777dfe4c62
4 changed files with 15 additions and 10 deletions

View file

@ -30,6 +30,9 @@ namespace LibationWinForms.GridView
public bool SupportsFiltering => true;
public string Filter { get => FilterString; set => ApplyFilter(value); }
/// <summary>When true, itms will not be checked filtered by search criteria on item changed<summary>
public bool SuspendFilteringOnUpdate { get; set; }
protected MemberComparer<GridEntry> Comparer { get; } = new();
protected override bool SupportsSortingCore => true;
protected override bool SupportsSearchingCore => true;
@ -195,7 +198,7 @@ namespace LibationWinForms.GridView
{
if (e.ListChangedType == ListChangedType.ItemChanged)
{
if (Items[e.NewIndex] is LibraryBookEntry lbItem)
if (FilterString is not null && !SuspendFilteringOnUpdate && Items[e.NewIndex] is LibraryBookEntry lbItem)
{
SearchResults = SearchEngineCommands.Search(FilterString);
if (!SearchResults.Docs.Any(d => d.ProductId == lbItem.AudibleProductId))