Fix not canceled token and adding comment

Co-authored-by: bao-qian <bao.github@outlook.com>
This commit is contained in:
弘韬 张 2020-11-11 19:06:05 +08:00
parent 52887aacf0
commit ebddf19ba2
2 changed files with 9 additions and 4 deletions

View file

@ -469,9 +469,9 @@ namespace Flow.Launcher.ViewModel
}
else
{
_updateSource?.Cancel();
Results.Clear();
Results.Visbility = Visibility.Collapsed;
}
}
@ -695,7 +695,9 @@ namespace Flow.Launcher.ViewModel
_saved = true;
}
}
/// <summary>
/// To avoid deadlock, this method should not called from main thread
/// </summary>
public void UpdateResultView(IEnumerable<ResultsForUpdate> resultsForUpdates)
{
foreach (var result in resultsForUpdates.SelectMany(u => u.Results))

View file

@ -174,7 +174,6 @@ namespace Flow.Launcher.ViewModel
Margin = new Thickness { Top = 0 };
Visbility = Visibility.Collapsed;
break;
}
}
@ -247,7 +246,7 @@ namespace Flow.Launcher.ViewModel
public class ResultCollection : ObservableCollection<ResultViewModel>, INotifyCollectionChanged
{
public event NotifyCollectionChangedEventHandler CollectionChanged;
public override event NotifyCollectionChangedEventHandler CollectionChanged;
public void RemoveAll()
{
ClearItems();
@ -259,12 +258,16 @@ namespace Flow.Launcher.ViewModel
/// <param name="newItems"></param>
public void Update(List<ResultViewModel> newItems)
{
ClearItems();
foreach (var item in newItems)
{
Add(item);
}
// wpf use directx / double buffered already, so just reset all won't cause ui flickering
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
return;