diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs
index da7a300324d..3e16f24c2f0 100644
--- a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs
+++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs
@@ -1259,6 +1259,8 @@ internal void SearchAndUpdateResults(string query)
else
{
results = Search(query, true);
+ results = ApplyNonHostFilters(results);
+ results = ApplyHostFilters(results);
}
this.ClearSearchResults();
@@ -1326,7 +1328,7 @@ internal void SearchAndUpdateResults()
///
///
///
- internal IEnumerable Filter(IEnumerable list)
+ internal IEnumerable ApplyHostFilters(IEnumerable list)
{
// No need to filter by host if nothing selected
if (SelectedHosts.Count == 0) return list;
@@ -1352,15 +1354,11 @@ internal IEnumerable GetAllPackages()
// Filter based on user preference
// A package has depndencies if the number of direct_dependency_ids is more than 1
- list = Filter(LastSync.Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterDeprecated)).OnChecked ? x.IsDeprecated : !x.IsDeprecated)
- .Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageManagerPackageNew)).OnChecked ? IsNewPackage(x) : true)
- .Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageManagerPackageUpdated)).OnChecked ? IsUpdatedPackage(x) : true)
- .Where(x => !NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterDependencies)).OnChecked ? true : PackageHasDependencies(x))
- .Where(x => !NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterNoDependencies)).OnChecked ? true : !PackageHasDependencies(x))
- ?.Select(x => new PackageManagerSearchElementViewModel(x,
+ var initialResults = LastSync?.Select(x => new PackageManagerSearchElementViewModel(x,
PackageManagerClientViewModel.AuthenticationManager.HasAuthProvider,
- CanInstallPackage(x.Name), isEnabledForInstall)))
- .ToList();
+ CanInstallPackage(x.Name), isEnabledForInstall));
+ list = ApplyNonHostFilters(initialResults);
+ list = ApplyHostFilters(list).ToList();
Sort(list, this.SortingKey);
@@ -1375,6 +1373,21 @@ internal IEnumerable GetAllPackages()
return list;
}
+ ///
+ /// Applies non-host filters to a list of PackageManagerSearchElementViewModel
+ ///
+ /// The list to filter
+ ///
+ private List ApplyNonHostFilters(IEnumerable list)
+ {
+ return list.Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterDeprecated)).OnChecked ? x.SearchElementModel.IsDeprecated : !x.SearchElementModel.IsDeprecated)
+ .Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageManagerPackageNew)).OnChecked ? IsNewPackage(x.SearchElementModel) : true)
+ .Where(x => NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageManagerPackageUpdated)).OnChecked ? IsUpdatedPackage(x.SearchElementModel) : true)
+ .Where(x => !NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterDependencies)).OnChecked ? true : PackageHasDependencies(x.SearchElementModel))
+ .Where(x => !NonHostFilter.First(f => f.FilterName.Equals(Resources.PackageSearchViewContextMenuFilterNoDependencies)).OnChecked ? true : !PackageHasDependencies(x.SearchElementModel))
+ .ToList();
+ }
+
///
/// Checks if a package has any dependencies (will always have at least itself as 1 dependency)
///