Skip to content

Commit 0b05e95

Browse files
committed
add Query.IsForced property
When a plugin is processing a query, it can check the `IsForced` property to decide if the results will be served from cache or not.
1 parent fa2c894 commit 0b05e95

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

Flow.Launcher.Plugin/Query.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm
2929
/// </summary>
3030
public string RawQuery { get; internal init; }
3131

32+
/// <summary>
33+
/// Determines whether the query was forced to execute again.
34+
/// When this property is true, plugins handling this query should avoid serving cached results.
35+
/// </summary>
36+
public bool IsForced { get; internal set; } = false;
37+
3238
/// <summary>
3339
/// Search part of a query.
3440
/// 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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading;
@@ -512,7 +512,7 @@ public void ChangeQueryText(string queryText, bool reQuery = false)
512512
}
513513
else if (reQuery)
514514
{
515-
Query();
515+
Query(reQuery: true);
516516
}
517517
QueryTextCursorMovedToEnd = true;
518518
});
@@ -612,11 +612,11 @@ public string PreviewHotkey
612612

613613
#region Query
614614

615-
public void Query()
615+
public void Query(bool reQuery = false)
616616
{
617617
if (SelectedIsFromQueryResults())
618618
{
619-
QueryResults();
619+
QueryResults(reQuery);
620620
}
621621
else if (ContextMenuSelected())
622622
{
@@ -716,7 +716,7 @@ private void QueryHistory()
716716

717717
private readonly IReadOnlyList<Result> _emptyResult = new List<Result>();
718718

719-
private async void QueryResults()
719+
private async void QueryResults(bool reQuery = false)
720720
{
721721
_updateSource?.Cancel();
722722

@@ -747,6 +747,8 @@ private async void QueryResults()
747747
if (currentCancellationToken.IsCancellationRequested)
748748
return;
749749

750+
// Update the query's IsForced property to true if this is a re-query
751+
query.IsForced = reQuery;
750752

751753
// handle the exclusiveness of plugin using action keyword
752754
RemoveOldQueryResults(query);

0 commit comments

Comments
 (0)