Skip to content

Commit

Permalink
Delay applying filters on refilter
Browse files Browse the repository at this point in the history
  • Loading branch information
DSPaul committed Feb 20, 2023
1 parent 629b619 commit 9d7905f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ViewModels/FilterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,25 +349,25 @@ public void ClearFilters()


//------------- Filter Logic ------------//
private void UpdateIncludedCodices()
private void UpdateIncludedCodices(bool apply = true)
{
IncludedCodices = new(_allCodices);
foreach (Filter.FilterType filterType in Enum.GetValues(typeof(Filter.FilterType)))
{
// Included codices must match filters of all types so IntersectWith()
IncludedCodices.IntersectWith(GetFilteredCodicesByType(IncludedFilters, filterType, true));
}
ApplyFilters();
if (apply) ApplyFilters();
}
private void UpdateExcludedCodices()
private void UpdateExcludedCodices(bool apply = true)
{
ExcludedCodices = new();
foreach (Filter.FilterType filterType in Enum.GetValues(typeof(Filter.FilterType)))
{
// Codex is excluded as soon as it matches any excluded filter so UnionWith()
ExcludedCodices.UnionWith(GetFilteredCodicesByType(ExcludedFilters, filterType, false));
}
ApplyFilters();
if (apply) ApplyFilters();
}

/// <summary>
Expand Down Expand Up @@ -490,8 +490,9 @@ private void ApplyFilters()

public void ReFilter()
{
UpdateIncludedCodices();
UpdateExcludedCodices();
UpdateIncludedCodices(false);
UpdateExcludedCodices(false);
ApplyFilters();
}
public void RemoveCodex(Codex c)
{
Expand Down

0 comments on commit 9d7905f

Please sign in to comment.