mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3503 from Flow-Launcher/do_not_query_when_back_from_context_menu
Do not query again when setting private field of QueryText
This commit is contained in:
commit
a2a8c5081e
1 changed files with 25 additions and 7 deletions
|
|
@ -34,6 +34,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
private bool _isQueryRunning;
|
private bool _isQueryRunning;
|
||||||
private Query _lastQuery;
|
private Query _lastQuery;
|
||||||
private string _queryTextBeforeLeaveResults;
|
private string _queryTextBeforeLeaveResults;
|
||||||
|
private string _ignoredQueryText = null;
|
||||||
|
|
||||||
private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
|
private readonly FlowLauncherJsonStorage<History> _historyItemsStorage;
|
||||||
private readonly FlowLauncherJsonStorage<UserSelectedRecord> _userSelectedRecordStorage;
|
private readonly FlowLauncherJsonStorage<UserSelectedRecord> _userSelectedRecordStorage;
|
||||||
|
|
@ -730,6 +731,9 @@ namespace Flow.Launcher.ViewModel
|
||||||
if (isReturningFromContextMenu)
|
if (isReturningFromContextMenu)
|
||||||
{
|
{
|
||||||
_queryText = _queryTextBeforeLeaveResults;
|
_queryText = _queryTextBeforeLeaveResults;
|
||||||
|
// When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
|
||||||
|
// So we need to ignore it so that we will not call Query again
|
||||||
|
_ignoredQueryText = _queryText;
|
||||||
OnPropertyChanged(nameof(QueryText));
|
OnPropertyChanged(nameof(QueryText));
|
||||||
QueryTextCursorMovedToEnd = true;
|
QueryTextCursorMovedToEnd = true;
|
||||||
}
|
}
|
||||||
|
|
@ -1076,6 +1080,20 @@ namespace Flow.Launcher.ViewModel
|
||||||
|
|
||||||
public void Query(bool searchDelay, bool isReQuery = false)
|
public void Query(bool searchDelay, bool isReQuery = false)
|
||||||
{
|
{
|
||||||
|
if (_ignoredQueryText != null)
|
||||||
|
{
|
||||||
|
if (_ignoredQueryText == QueryText)
|
||||||
|
{
|
||||||
|
_ignoredQueryText = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If _ignoredQueryText does not match current QueryText, we should still execute Query
|
||||||
|
_ignoredQueryText = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (QueryResultsSelected())
|
if (QueryResultsSelected())
|
||||||
{
|
{
|
||||||
_ = QueryResultsAsync(searchDelay, isReQuery);
|
_ = QueryResultsAsync(searchDelay, isReQuery);
|
||||||
|
|
@ -1170,7 +1188,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
OriginQuery = new Query { RawQuery = h.Query },
|
OriginQuery = new Query { RawQuery = h.Query },
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
SelectedResults = Results;
|
App.API.BackToQueryResults();
|
||||||
App.API.ChangeQuery(h.Query);
|
App.API.ChangeQuery(h.Query);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1414,11 +1432,14 @@ namespace Flow.Launcher.ViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show expanded builtin shortcuts
|
||||||
if (queryChanged)
|
if (queryChanged)
|
||||||
{
|
{
|
||||||
// show expanded builtin shortcuts
|
// Use private field to avoid infinite recursion
|
||||||
// use private field to avoid infinite recursion
|
|
||||||
_queryText = queryBuilderTmp.ToString();
|
_queryText = queryBuilderTmp.ToString();
|
||||||
|
// When executing OnPropertyChanged, QueryTextBox_TextChanged1 and Query will be called
|
||||||
|
// So we need to ignore it so that we will not call Query again
|
||||||
|
_ignoredQueryText = _queryText;
|
||||||
OnPropertyChanged(nameof(QueryText));
|
OnPropertyChanged(nameof(QueryText));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1600,10 +1621,7 @@ namespace Flow.Launcher.ViewModel
|
||||||
await CloseExternalPreviewAsync();
|
await CloseExternalPreviewAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!QueryResultsSelected())
|
BackToQueryResults();
|
||||||
{
|
|
||||||
SelectedResults = Results;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Settings.LastQueryMode)
|
switch (Settings.LastQueryMode)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue