mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -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:
@ -376,12 +376,15 @@ if ($sync["ISOLanguage"].Items.Count -eq 1) {
|
||||
}
|
||||
$sync["ISOLanguage"].SelectedIndex = 0
|
||||
|
||||
$sync["SearchBar"].Add_TextChanged({
|
||||
if ($sync.SearchBar.Text -ne "") {
|
||||
$sync.SearchBarClearButton.Visibility = "Visible"
|
||||
} else {
|
||||
$sync.SearchBarClearButton.Visibility = "Collapsed"
|
||||
}
|
||||
# The SearchBarTimer is used to delay the search operation until the user has stopped typing for a short period
|
||||
# This prevents the ui from stuttering when the user types quickly as it dosnt need to update the ui for every keystroke
|
||||
|
||||
$searchBarTimer = New-Object System.Windows.Threading.DispatcherTimer
|
||||
$searchBarTimer.Interval = [TimeSpan]::FromMilliseconds(300)
|
||||
$searchBarTimer.IsEnabled = $false
|
||||
|
||||
$searchBarTimer.add_Tick({
|
||||
$searchBarTimer.Stop()
|
||||
switch ($sync.currentTab) {
|
||||
"Install" {
|
||||
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({
|
||||
param($e)
|
||||
|
Reference in New Issue
Block a user