Skip to content

Commit 28b8cb6

Browse files
committed
Improve distinguish between home query and global query
1 parent 21d6ec2 commit 28b8cb6

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Flow.Launcher.Core/Plugin/QueryBuilder.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalP
1616
Search = string.Empty,
1717
RawQuery = string.Empty,
1818
SearchTerms = Array.Empty<string>(),
19-
// must use null because we need to distinguish between home query and global query
20-
ActionKeyword = null
19+
ActionKeyword = string.Empty
2120
};
2221
}
2322

Flow.Launcher.Plugin/Query.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public class Query
5353
/// <summary>
5454
/// The action keyword part of this query.
5555
/// For global plugins this value will be empty.
56-
/// For home query this value will be null.
5756
/// </summary>
5857
public string ActionKeyword { get; init; }
5958

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
3333

3434
private bool _isQueryRunning;
3535
private Query _lastQuery;
36+
private bool _lastHomeQuery;
3637
private string _queryTextBeforeLeaveResults;
3738
private string _ignoredQueryText = null;
3839

@@ -1261,6 +1262,8 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12611262
return;
12621263
}
12631264

1265+
var homeQuery = query.RawQuery == string.Empty;
1266+
12641267
_updateSource = new CancellationTokenSource();
12651268

12661269
ProgressBarVisibility = Visibility.Hidden;
@@ -1275,11 +1278,11 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12751278
query.IsReQuery = isReQuery;
12761279

12771280
// handle the exclusiveness of plugin using action keyword
1278-
RemoveOldQueryResults(query);
1281+
RemoveOldQueryResults(query, homeQuery);
12791282

12801283
_lastQuery = query;
1284+
_lastHomeQuery = homeQuery;
12811285

1282-
var homeQuery = query.RawQuery == string.Empty;
12831286
ICollection<PluginPair> plugins = Array.Empty<PluginPair>();
12841287
if (homeQuery)
12851288
{
@@ -1524,9 +1527,15 @@ private async Task BuildQueryAsync(IEnumerable<BaseBuiltinShortcutModel> builtIn
15241527
}
15251528
}
15261529

1527-
private void RemoveOldQueryResults(Query query)
1530+
private void RemoveOldQueryResults(Query query, bool homeQuery)
15281531
{
1529-
if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
1532+
// If last or current query is home query, we need to clear the results
1533+
if (_lastHomeQuery || homeQuery)
1534+
{
1535+
Results.Clear();
1536+
}
1537+
// If last and current query are not home query, we need to check action keyword
1538+
else if (_lastQuery?.ActionKeyword != query?.ActionKeyword)
15301539
{
15311540
Results.Clear();
15321541
}

0 commit comments

Comments
 (0)