1
- using System ;
1
+ using Flow . Launcher . Infrastructure . UserSettings ;
2
+ using Flow . Launcher . Plugin ;
2
3
using System . Collections . Generic ;
3
- using System . Collections . ObjectModel ;
4
4
using System . Collections . Specialized ;
5
5
using System . Linq ;
6
6
using System . Threading ;
7
- using System . Threading . Tasks ;
8
7
using System . Windows ;
9
8
using System . Windows . Controls ;
10
9
using System . Windows . Data ;
11
10
using System . Windows . Documents ;
12
- using Flow . Launcher . Infrastructure . UserSettings ;
13
- using Flow . Launcher . Plugin ;
14
11
15
12
namespace Flow . Launcher . ViewModel
16
13
{
@@ -146,7 +143,7 @@ public void AddResults(List<Result> newRawResults, string resultId)
146
143
/// <summary>
147
144
/// To avoid deadlock, this method should not called from main thread
148
145
/// </summary>
149
- public void AddResults ( IEnumerable < ResultsForUpdate > resultsForUpdates , CancellationToken token )
146
+ public void AddResults ( IReadOnlyCollection < ResultsForUpdate > resultsForUpdates , CancellationToken token )
150
147
{
151
148
var newResults = NewResults ( resultsForUpdates ) ;
152
149
@@ -192,10 +189,11 @@ private List<ResultViewModel> NewResults(List<Result> newRawResults, string resu
192
189
return results . Where ( r => r . Result . PluginID != resultId )
193
190
. Concat ( newResults )
194
191
. OrderByDescending ( r => r . Result . Score )
192
+ . Distinct ( )
195
193
. ToList ( ) ;
196
194
}
197
195
198
- private List < ResultViewModel > NewResults ( IEnumerable < ResultsForUpdate > resultsForUpdates )
196
+ private List < ResultViewModel > NewResults ( IReadOnlyCollection < ResultsForUpdate > resultsForUpdates )
199
197
{
200
198
if ( ! resultsForUpdates . Any ( ) )
201
199
return Results . ToList ( ) ;
@@ -205,6 +203,7 @@ private List<ResultViewModel> NewResults(IEnumerable<ResultsForUpdate> resultsFo
205
203
return results . Where ( r => r != null && ! resultsForUpdates . Any ( u => u . Metadata . ID == r . Result . PluginID ) )
206
204
. Concat ( resultsForUpdates . SelectMany ( u => u . Results , ( u , r ) => new ResultViewModel ( r , _settings ) ) )
207
205
. OrderByDescending ( rv => rv . Result . Score )
206
+ . Distinct ( )
208
207
. ToList ( ) ;
209
208
}
210
209
#endregion
0 commit comments