Updated program execution to call action on background thread. (#2370)

This commit is contained in:
Divyansh Srivastava 2020-04-24 13:31:36 -07:00 committed by GitHub
parent 368640b59b
commit a6e8cbc50d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -114,8 +114,8 @@ namespace Wox.ViewModel
SelectPrevItemCommand = new RelayCommand(_ =>
{
SelectedResults.SelectPrevResult();
});
});
SelectNextTabItemCommand = new RelayCommand(_ =>
{
SelectedResults.SelectNextTabItem();
@ -152,37 +152,37 @@ namespace Wox.ViewModel
results.SelectedIndex = int.Parse(index.ToString());
}
if(results.SelectedItem != null)
{
//If there is a context button selected fire the action for that button before the main command.
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
if (!didExecuteContextButton)
{
var result = results.SelectedItem.Result;
if (result != null) // SelectedItem returns null if selection is empty.
{
bool hideWindow = result.Action != null && result.Action(new ActionContext
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
if (hideWindow)
{
MainWindowVisibility = Visibility.Collapsed;
}
if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery);
}
else
{
SelectedResults = Results;
}
}
}
if(results.SelectedItem != null)
{
//If there is a context button selected fire the action for that button before the main command.
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
if (!didExecuteContextButton)
{
var result = results.SelectedItem.Result;
if (result != null && result.Action != null) // SelectedItem returns null if selection is empty.
{
MainWindowVisibility = Visibility.Collapsed;
Task.Run(() =>
{
result.Action(new ActionContext
{
SpecialKeyState = GlobalHotkey.Instance.CheckModifiers()
});
});
if (SelectedIsFromQueryResults())
{
_userSelectedRecord.Add(result);
_history.Add(result.OriginQuery.RawQuery);
}
else
{
SelectedResults = Results;
}
}
}
}
});
@ -289,8 +289,8 @@ namespace Wox.ViewModel
public ICommand EscCommand { get; set; }
public ICommand SelectNextItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; }
public ICommand SelectPrevItemCommand { get; set; }
public ICommand SelectNextTabItemCommand { get; set; }
public ICommand SelectPrevTabItemCommand { get; set; }