mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
Improving UI performance (#5216)
* Added fast observable collection * Updated to use 1 collection changed event per query * Moved result updating to background thread * Changed collapsed to hidden for virtualization * Moved all token cancellations inside try catch * Fixed freeze on deleting first letter * nit fixes * Moved update logic to plugin result loop * Updated doc comment for AddResults function * fix result clear on empty query
This commit is contained in:
committed by
GitHub
parent
5fb7d43aff
commit
87ae1c6a9b
@@ -17,7 +17,6 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public ResultCollection Results { get; }
|
||||
|
||||
private readonly object _addResultsLock = new object();
|
||||
private readonly object _collectionLock = new object();
|
||||
private readonly Settings _settings;
|
||||
// private int MaxResults => _settings?.MaxResultsToShow ?? 6;
|
||||
@@ -154,12 +153,12 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
public void RemoveResultsExcept(PluginMetadata metadata)
|
||||
{
|
||||
Results.RemoveAll(r => r.Result.PluginID != metadata.ID);
|
||||
Results.RemovePredicate(r => r.Result.PluginID != metadata.ID);
|
||||
}
|
||||
|
||||
public void RemoveResultsFor(PluginMetadata metadata)
|
||||
{
|
||||
Results.RemoveAll(r => r.Result.PluginID == metadata.ID);
|
||||
Results.RemovePredicate(r => r.Result.PluginID == metadata.ID);
|
||||
}
|
||||
|
||||
public void SelectNextTabItem()
|
||||
@@ -214,28 +213,12 @@ namespace PowerLauncher.ViewModel
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To avoid deadlock, this method should not called from main thread
|
||||
/// Add new results to ResultCollection
|
||||
/// </summary>
|
||||
public void AddResults(List<Result> newRawResults, string resultId)
|
||||
{
|
||||
lock (_addResultsLock)
|
||||
{
|
||||
var newResults = NewResults(newRawResults, resultId);
|
||||
|
||||
// update UI in one run, so it can avoid UI flickering
|
||||
Results.Update(newResults);
|
||||
|
||||
if (Results.Count > 0)
|
||||
{
|
||||
Margin = new Thickness { Top = 8 };
|
||||
SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Margin = new Thickness { Top = 0 };
|
||||
Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
{
|
||||
var newResults = NewResults(newRawResults, resultId);
|
||||
Results.Update(newResults);
|
||||
}
|
||||
|
||||
private List<ResultViewModel> NewResults(List<Result> newRawResults, string resultId)
|
||||
|
||||
Reference in New Issue
Block a user