mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-05-24 00:07:24 -05:00
Implement search bar debounce functionality to improve UI responsiveness (#3371)
* Implement search bar debounce functionality to improve UI responsiveness * Enhance app search functionality to include description matching
This commit is contained in:
parent
dd06489d63
commit
0c0e6bd243
@ -34,7 +34,8 @@ function Find-AppsByNameOrDescription {
|
|||||||
if ($_.Tag -like "CategoryWrapPanel_*") {
|
if ($_.Tag -like "CategoryWrapPanel_*") {
|
||||||
# Search for Apps that match the search string
|
# Search for Apps that match the search string
|
||||||
$_.Children | Foreach-Object {
|
$_.Children | Foreach-Object {
|
||||||
if ($sync.configs.applicationsHashtable.$($_.Tag).Content -like "*$SearchString*") {
|
$appEntry = $sync.configs.applicationsHashtable.$($_.Tag)
|
||||||
|
if ($appEntry.Content -like "*$SearchString*" -or $appEntry.Description -like "*$SearchString*") {
|
||||||
# Show the App and the parent CategoryWrapPanel if the string is found
|
# Show the App and the parent CategoryWrapPanel if the string is found
|
||||||
$_.Visibility = [Windows.Visibility]::Visible
|
$_.Visibility = [Windows.Visibility]::Visible
|
||||||
$_.parent.Visibility = [Windows.Visibility]::Visible
|
$_.parent.Visibility = [Windows.Visibility]::Visible
|
||||||
|
@ -376,12 +376,15 @@ if ($sync["ISOLanguage"].Items.Count -eq 1) {
|
|||||||
}
|
}
|
||||||
$sync["ISOLanguage"].SelectedIndex = 0
|
$sync["ISOLanguage"].SelectedIndex = 0
|
||||||
|
|
||||||
$sync["SearchBar"].Add_TextChanged({
|
# The SearchBarTimer is used to delay the search operation until the user has stopped typing for a short period
|
||||||
if ($sync.SearchBar.Text -ne "") {
|
# This prevents the ui from stuttering when the user types quickly as it dosnt need to update the ui for every keystroke
|
||||||
$sync.SearchBarClearButton.Visibility = "Visible"
|
|
||||||
} else {
|
$searchBarTimer = New-Object System.Windows.Threading.DispatcherTimer
|
||||||
$sync.SearchBarClearButton.Visibility = "Collapsed"
|
$searchBarTimer.Interval = [TimeSpan]::FromMilliseconds(300)
|
||||||
}
|
$searchBarTimer.IsEnabled = $false
|
||||||
|
|
||||||
|
$searchBarTimer.add_Tick({
|
||||||
|
$searchBarTimer.Stop()
|
||||||
switch ($sync.currentTab) {
|
switch ($sync.currentTab) {
|
||||||
"Install" {
|
"Install" {
|
||||||
Find-AppsByNameOrDescription -SearchString $sync.SearchBar.Text
|
Find-AppsByNameOrDescription -SearchString $sync.SearchBar.Text
|
||||||
@ -391,6 +394,17 @@ $sync["SearchBar"].Add_TextChanged({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
$sync["SearchBar"].Add_TextChanged({
|
||||||
|
if ($sync.SearchBar.Text -ne "") {
|
||||||
|
$sync.SearchBarClearButton.Visibility = "Visible"
|
||||||
|
} else {
|
||||||
|
$sync.SearchBarClearButton.Visibility = "Collapsed"
|
||||||
|
}
|
||||||
|
if ($searchBarTimer.IsEnabled) {
|
||||||
|
$searchBarTimer.Stop()
|
||||||
|
}
|
||||||
|
$searchBarTimer.Start()
|
||||||
|
})
|
||||||
|
|
||||||
$sync["Form"].Add_Loaded({
|
$sync["Form"].Add_Loaded({
|
||||||
param($e)
|
param($e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user