From 0b05e954e5d2dcf949e4a5d9332849ca90be86b7 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Tue, 6 Jun 2023 12:57:44 +0300 Subject: [PATCH 1/4] 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. --- Flow.Launcher.Plugin/Query.cs | 6 ++++++ Flow.Launcher/ViewModel/MainViewModel.cs | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Flow.Launcher.Plugin/Query.cs b/Flow.Launcher.Plugin/Query.cs index 95547d27350..615729b61e1 100644 --- a/Flow.Launcher.Plugin/Query.cs +++ b/Flow.Launcher.Plugin/Query.cs @@ -29,6 +29,12 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm /// public string RawQuery { get; internal init; } + /// + /// Determines whether the query was forced to execute again. + /// When this property is true, plugins handling this query should avoid serving cached results. + /// + public bool IsForced { get; internal set; } = false; + /// /// Search part of a query. /// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery. diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 8529df7b313..5d21341e3bb 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -512,7 +512,7 @@ public void ChangeQueryText(string queryText, bool reQuery = false) } else if (reQuery) { - Query(); + Query(reQuery: true); } QueryTextCursorMovedToEnd = true; }); @@ -612,11 +612,11 @@ public string PreviewHotkey #region Query - public void Query() + public void Query(bool reQuery = false) { if (SelectedIsFromQueryResults()) { - QueryResults(); + QueryResults(reQuery); } else if (ContextMenuSelected()) { @@ -716,7 +716,7 @@ private void QueryHistory() private readonly IReadOnlyList _emptyResult = new List(); - private async void QueryResults() + private async void QueryResults(bool reQuery = false) { _updateSource?.Cancel(); @@ -747,6 +747,8 @@ private async void QueryResults() if (currentCancellationToken.IsCancellationRequested) return; + // Update the query's IsForced property to true if this is a re-query + query.IsForced = reQuery; // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); From fa783a9cd46c2ab3559aaa297135a845a3287e31 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Tue, 6 Jun 2023 13:06:39 +0300 Subject: [PATCH 2/4] bind `Ctrl + R` to re-running the current query --- Flow.Launcher/MainWindow.xaml | 4 ++++ Flow.Launcher/ViewModel/MainViewModel.cs | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 4a95834b534..f864815e4f3 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -86,6 +86,10 @@ Key="O" Command="{Binding LoadContextMenuCommand}" Modifiers="Ctrl" /> + Date: Wed, 7 Jun 2023 23:19:47 +0300 Subject: [PATCH 3/4] Query: rename `IsForced` property to `IsReQuery` --- Flow.Launcher.Plugin/Query.cs | 3 ++- Flow.Launcher/ViewModel/MainViewModel.cs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Flow.Launcher.Plugin/Query.cs b/Flow.Launcher.Plugin/Query.cs index 615729b61e1..3ee44f6b6a9 100644 --- a/Flow.Launcher.Plugin/Query.cs +++ b/Flow.Launcher.Plugin/Query.cs @@ -31,9 +31,10 @@ public Query(string rawQuery, string search, string[] terms, string[] searchTerm /// /// Determines whether the query was forced to execute again. + /// For example, the value will be true when the user presses Ctrl + R. /// When this property is true, plugins handling this query should avoid serving cached results. /// - public bool IsForced { get; internal set; } = false; + public bool IsReQuery { get; internal set; } = false; /// /// Search part of a query. diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index c051cd3d1af..a0c1e8479fd 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -756,8 +756,8 @@ private async void QueryResults(bool reQuery = false) if (currentCancellationToken.IsCancellationRequested) return; - // Update the query's IsForced property to true if this is a re-query - query.IsForced = reQuery; + // Update the query's IsReQuery property to true if this is a re-query + query.IsReQuery = reQuery; // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query); From f22ce3788da38415ebd2e35958a04799e75c8c21 Mon Sep 17 00:00:00 2001 From: Ioannis G Date: Sun, 11 Jun 2023 16:19:41 +0300 Subject: [PATCH 4/4] rename params to isReQuery for consistency --- Flow.Launcher/ViewModel/MainViewModel.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index a0c1e8479fd..37e993c28ab 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -210,7 +210,7 @@ private void ReQuery() { if (SelectedIsFromQueryResults()) { - QueryResults(reQuery: true); + QueryResults(isReQuery: true); } } @@ -504,8 +504,8 @@ private void UpdatePreview() /// but we don't want to move cursor to end when query is updated from TextBox /// /// - /// Force query even when Query Text doesn't change - public void ChangeQueryText(string queryText, bool reQuery = false) + /// Force query even when Query Text doesn't change + public void ChangeQueryText(string queryText, bool isReQuery = false) { Application.Current.Dispatcher.Invoke(() => { @@ -519,9 +519,9 @@ public void ChangeQueryText(string queryText, bool reQuery = false) QueryTextCursorMovedToEnd = false; } - else if (reQuery) + else if (isReQuery) { - Query(reQuery: true); + Query(isReQuery: true); } QueryTextCursorMovedToEnd = true; }); @@ -621,11 +621,11 @@ public string PreviewHotkey #region Query - public void Query(bool reQuery = false) + public void Query(bool isReQuery = false) { if (SelectedIsFromQueryResults()) { - QueryResults(reQuery); + QueryResults(isReQuery); } else if (ContextMenuSelected()) { @@ -725,7 +725,7 @@ private void QueryHistory() private readonly IReadOnlyList _emptyResult = new List(); - private async void QueryResults(bool reQuery = false) + private async void QueryResults(bool isReQuery = false) { _updateSource?.Cancel(); @@ -757,7 +757,7 @@ private async void QueryResults(bool reQuery = false) return; // Update the query's IsReQuery property to true if this is a re-query - query.IsReQuery = reQuery; + query.IsReQuery = isReQuery; // handle the exclusiveness of plugin using action keyword RemoveOldQueryResults(query);