Skip to content

Commit 5784f87

Browse files
committed
Make sure results cleared when update tasks are not called
1 parent 54d50cf commit 5784f87

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13401340

13411341
// plugins are ICollection, meaning LINQ will get the Count and preallocate Array
13421342

1343+
var resultsCleared = false;
13431344
Task[] tasks;
13441345
if (currentIsHomeQuery)
13451346
{
@@ -1374,6 +1375,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13741375
// nothing to do here
13751376
}
13761377

1378+
// If results are not cleared, we need to clear the results
1379+
if (!resultsCleared) Results.Clear();
1380+
13771381
if (currentCancellationToken.IsCancellationRequested) return;
13781382

13791383
// this should happen once after all queries are done so progress bar should continue
@@ -1443,6 +1447,11 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
14431447
{
14441448
App.API.LogError(ClassName, "Unable to add item to Result Update Queue");
14451449
}
1450+
else
1451+
{
1452+
// Only update the clear flag when we successfully write to the channel
1453+
resultsCleared = true;
1454+
}
14461455
}
14471456

14481457
void QueryHistoryTask(CancellationToken token)
@@ -1466,6 +1475,11 @@ void QueryHistoryTask(CancellationToken token)
14661475
{
14671476
App.API.LogError(ClassName, "Unable to add item to Result Update Queue");
14681477
}
1478+
else
1479+
{
1480+
// Only update the clear flag when we successfully write to the channel
1481+
resultsCleared = true;
1482+
}
14691483
}
14701484
}
14711485

0 commit comments

Comments
 (0)