Skip to content

Commit 09015f2

Browse files
committed
Handle isHomeQuery in Query class
1 parent b999fd0 commit 09015f2

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Flow.Launcher.Core/Plugin/QueryBuilder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalP
1616
Search = string.Empty,
1717
RawQuery = string.Empty,
1818
SearchTerms = Array.Empty<string>(),
19-
ActionKeyword = string.Empty
19+
ActionKeyword = string.Empty,
20+
IsHomeQuery = true
2021
};
2122
}
2223

@@ -53,7 +54,8 @@ public static Query Build(string text, Dictionary<string, PluginPair> nonGlobalP
5354
Search = search,
5455
RawQuery = rawQuery,
5556
SearchTerms = searchTerms,
56-
ActionKeyword = actionKeyword
57+
ActionKeyword = actionKeyword,
58+
IsHomeQuery = false
5759
};
5860
}
5961
}

Flow.Launcher.Plugin/Query.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public class Query
2121
/// </summary>
2222
public bool IsReQuery { get; internal set; } = false;
2323

24+
/// <summary>
25+
/// Determines whether the query is a home query.
26+
/// </summary>
27+
public bool IsHomeQuery { get; internal init; } = false;
28+
2429
/// <summary>
2530
/// Search part of a query.
2631
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.Collections.Generic;
43
using System.ComponentModel;
54
using System.Globalization;
@@ -217,7 +216,7 @@ async Task UpdateActionAsync()
217216
{
218217
// Indicate if to clear existing results so to show only ones from plugins with action keywords
219218
var query = item.Query;
220-
var currentIsHomeQuery = item.IsHomeQuery;
219+
var currentIsHomeQuery = query.IsHomeQuery;
221220
var shouldClearExistingResults = ShouldClearExistingResultsForQuery(query, currentIsHomeQuery);
222221
_lastQuery = item.Query;
223222
_previousIsHomeQuery = currentIsHomeQuery;
@@ -279,7 +278,7 @@ public void RegisterResultsUpdatedEvent()
279278
App.API.LogDebug(ClassName, $"Update results for plugin <{pair.Metadata.Name}>");
280279

281280
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(resultsCopy, pair.Metadata, e.Query,
282-
false, token)))
281+
token)))
283282
{
284283
App.API.LogError(ClassName, "Unable to add item to Result Update Queue");
285284
}
@@ -1271,7 +1270,7 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12711270

12721271
App.API.LogDebug(ClassName, $"Start query with ActionKeyword <{query.ActionKeyword}> and RawQuery <{query.RawQuery}>");
12731272

1274-
var currentIsHomeQuery = query.RawQuery == string.Empty;
1273+
var currentIsHomeQuery = query.IsHomeQuery;
12751274

12761275
_updateSource?.Dispose();
12771276

@@ -1446,7 +1445,7 @@ await PluginManager.QueryHomeForPluginAsync(plugin, query, token) :
14461445
App.API.LogDebug(ClassName, $"Update results for plugin <{plugin.Metadata.Name}>");
14471446

14481447
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(resultsCopy, plugin.Metadata, query,
1449-
currentIsHomeQuery, token, reSelect)))
1448+
token, reSelect)))
14501449
{
14511450
App.API.LogError(ClassName, "Unable to add item to Result Update Queue");
14521451
}
@@ -1464,7 +1463,7 @@ void QueryHistoryTask(CancellationToken token)
14641463
App.API.LogDebug(ClassName, $"Update results for history");
14651464

14661465
if (!_resultsUpdateChannelWriter.TryWrite(new ResultsForUpdate(results, _historyMetadata, query,
1467-
currentIsHomeQuery, token, reSelect)))
1466+
token, reSelect)))
14681467
{
14691468
App.API.LogError(ClassName, "Unable to add item to Result Update Queue");
14701469
}

Flow.Launcher/ViewModel/ResultsForUpdate.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public record struct ResultsForUpdate(
88
IReadOnlyList<Result> Results,
99
PluginMetadata Metadata,
1010
Query Query,
11-
bool IsHomeQuery,
1211
CancellationToken Token,
1312
bool ReSelectFirstResult = true,
1413
bool ShouldClearExistingResults = false)

0 commit comments

Comments
 (0)