Skip to content

Commit 8f23870

Browse files
committed
Back to original style for fixing task issues
1 parent 632dbeb commit 8f23870

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

Diff for: Flow.Launcher/ViewModel/MainViewModel.cs

+37-2
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,31 @@ private void DecreaseMaxResult()
640640
/// <param name="isReQuery">Force query even when Query Text doesn't change</param>
641641
public void ChangeQueryText(string queryText, bool isReQuery = false)
642642
{
643-
_ = ChangeQueryTextAsync(queryText, isReQuery);
643+
// Must check access so that we will not block the UI thread which causes window visibility issue
644+
if (!Application.Current.Dispatcher.CheckAccess())
645+
{
646+
Application.Current.Dispatcher.Invoke(() => ChangeQueryText(queryText, isReQuery));
647+
return;
648+
}
649+
650+
if (QueryText != queryText)
651+
{
652+
// Change query text first
653+
QueryText = queryText;
654+
// When we are changing query from codes, we should not delay the query
655+
Query(false, isReQuery: false);
656+
657+
// set to false so the subsequent set true triggers
658+
// PropertyChanged and MoveQueryTextToEnd is called
659+
QueryTextCursorMovedToEnd = false;
660+
}
661+
else if (isReQuery)
662+
{
663+
// When we are re-querying, we should not delay the query
664+
Query(false, isReQuery: true);
665+
}
666+
667+
QueryTextCursorMovedToEnd = true;
644668
}
645669

646670
/// <summary>
@@ -1050,7 +1074,18 @@ private bool QueryResultsPreviewed()
10501074

10511075
public void Query(bool searchDelay, bool isReQuery = false)
10521076
{
1053-
_ = QueryAsync(searchDelay, isReQuery);
1077+
if (QueryResultsSelected())
1078+
{
1079+
_ = QueryResultsAsync(searchDelay, isReQuery);
1080+
}
1081+
else if (ContextMenuSelected())
1082+
{
1083+
QueryContextMenu();
1084+
}
1085+
else if (HistorySelected())
1086+
{
1087+
QueryHistory();
1088+
}
10541089
}
10551090

10561091
private async Task QueryAsync(bool searchDelay, bool isReQuery = false)

0 commit comments

Comments
 (0)