Skip to content

Commit

Permalink
Further cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
nachmore committed Aug 10, 2022
1 parent 13c70a9 commit 30669e8
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Flow.Launcher.Core/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static void LoadPlugins(PluginsSettings settings)
/// Call initialize for all plugins
/// </summary>
/// <returns>return the list of failed to init plugins or null for none</returns>
public static async Task InitializePlugins(IPublicAPI api)
public static async Task InitializePluginsAsync(IPublicAPI api)
{
API = api;
var failedPlugins = new ConcurrentQueue<PluginPair>();
Expand Down
8 changes: 5 additions & 3 deletions Flow.Launcher.Test/Plugins/ExplorerTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin;
using Flow.Launcher.Plugin.Explorer;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.DirectoryInfo;
Expand All @@ -19,10 +19,12 @@ namespace Flow.Launcher.Test.Plugins
[TestFixture]
public class ExplorerTest
{
#pragma warning disable CS1998 // async method with no await (more readable to leave it async to match the tested signature)
private async Task<List<Result>> MethodWindowsIndexSearchReturnsZeroResultsAsync(Query dummyQuery, string dummyString, CancellationToken dummyToken)
{
return new List<Result>();
}
#pragma warning restore CS1998

private List<Result> MethodDirectoryInfoClassSearchReturnsTwoResults(Query dummyQuery, string dummyString, CancellationToken token)
{
Expand Down Expand Up @@ -151,7 +153,7 @@ public void GivenWindowsIndexSearch_WhenSearchAllFoldersAndFiles_ThenQueryShould
}

[TestCase]
public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldContinueDirectoryInfoClassSearch()
public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldContinueDirectoryInfoClassSearchAsync()
{
// Given
var searchManager = new SearchManager(new Settings(), new PluginInitContext());
Expand All @@ -172,7 +174,7 @@ public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSe
}

[TestCase]
public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldNotContinueDirectoryInfoClassSearch()
public async Task GivenTopLevelDirectorySearch_WhenIndexSearchNotRequired_ThenSearchMethodShouldNotContinueDirectoryInfoClassSearchAsync()
{
// Given
var searchManager = new SearchManager(new Settings(), new PluginInitContext());
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
Http.API = API;
Http.Proxy = _settings.Proxy;

await PluginManager.InitializePlugins(API);
await PluginManager.InitializePluginsAsync(API);
var window = new MainWindow(_settings, _mainVM);

Log.Info($"|App.OnStartup|Dependencies Info:{ErrorReporting.DependenciesInfo()}");
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void UpdateItem(CustomPluginHotkey item)
}

tbAction.Text = updateCustomHotkey.ActionKeyword;
_ = ctlHotkey.SetHotkey(updateCustomHotkey.Hotkey, false);
_ = ctlHotkey.SetHotkeyAsync(updateCustomHotkey.Hotkey, false);
update = true;
lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update");
}
Expand Down
8 changes: 4 additions & 4 deletions Flow.Launcher/HotkeyControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ private void TbHotkey_OnPreviewKeyDown(object sender, KeyEventArgs e)
{
await Task.Delay(500, token);
if (!token.IsCancellationRequested)
await SetHotkey(hotkeyModel);
await SetHotkeyAsync(hotkeyModel);
});
}

public async Task SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
public async Task SetHotkeyAsync(HotkeyModel keyModel, bool triggerValidate = true)
{
CurrentHotkey = keyModel;

Expand Down Expand Up @@ -101,9 +101,9 @@ public async Task SetHotkey(HotkeyModel keyModel, bool triggerValidate = true)
}
}

public async Task SetHotkey(string keyStr, bool triggerValidate = true)
public async Task SetHotkeyAsync(string keyStr, bool triggerValidate = true)
{
_ = SetHotkey(new HotkeyModel(keyStr), triggerValidate);
await SetHotkeyAsync(new HotkeyModel(keyStr), triggerValidate);
}

private bool CheckHotkeyAvailability() => HotKeyMapper.CheckAvailability(CurrentHotkey);
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/Resources/Pages/WelcomePage2.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
tbMsgTextOriginal = HotkeyControl.tbMsg.Text;
tbMsgForegroundColorOriginal = HotkeyControl.tbMsg.Foreground;

HotkeyControl.SetHotkey(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey), false);
HotkeyControl.SetHotkeyAsync(new Infrastructure.Hotkey.HotkeyModel(Settings.Hotkey), false);
}
private void HotkeyControl_OnGotFocus(object sender, RoutedEventArgs args)
{
Expand Down
2 changes: 1 addition & 1 deletion Flow.Launcher/SettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private void OnSelectDefaultBrowserClick(object sender, RoutedEventArgs e)

private void OnHotkeyControlLoaded(object sender, RoutedEventArgs e)
{
_ = HotkeyControl.SetHotkey(viewModel.Settings.Hotkey, false);
_ = HotkeyControl.SetHotkeyAsync(viewModel.Settings.Hotkey, false);
}

private void OnHotkeyControlFocused(object sender, RoutedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.PluginsManager/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
//search could be url, no need ToLower() when passed in
Settings.InstallCommand => await pluginManager.RequestInstallOrUpdate(query.SecondToEndSearch, token),
Settings.UninstallCommand => pluginManager.RequestUninstall(query.SecondToEndSearch),
Settings.UpdateCommand => await pluginManager.RequestUpdate(query.SecondToEndSearch, token),
Settings.UpdateCommand => await pluginManager.RequestUpdateAsync(query.SecondToEndSearch, token),
_ => pluginManager.GetDefaultHotKeys().Where(hotkey =>
{
hotkey.Score = StringMatcher.FuzzySearch(query.Search, hotkey.Title).Score;
Expand Down
12 changes: 6 additions & 6 deletions Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http;
Expand Down Expand Up @@ -109,7 +109,7 @@ internal List<Result> GetDefaultHotKeys()
};
}

internal async Task InstallOrUpdate(UserPlugin plugin)
internal async Task InstallOrUpdateAsync(UserPlugin plugin)
{
if (PluginExists(plugin.ID))
{
Expand Down Expand Up @@ -182,7 +182,7 @@ internal async Task InstallOrUpdate(UserPlugin plugin)
Context.API.RestartApp();
}

internal async ValueTask<List<Result>> RequestUpdate(string search, CancellationToken token)
internal async ValueTask<List<Result>> RequestUpdateAsync(string search, CancellationToken token)
{
await UpdateManifestAsync(token);

Expand Down Expand Up @@ -336,7 +336,7 @@ internal List<Result> InstallFromWeb(string url)
}

Application.Current.MainWindow.Hide();
_ = InstallOrUpdate(plugin);
_ = InstallOrUpdateAsync(plugin);

return ShouldHideWindow;
}
Expand Down Expand Up @@ -383,7 +383,7 @@ internal async ValueTask<List<Result>> RequestInstallOrUpdate(string search, Can
}

Application.Current.MainWindow.Hide();
_ = InstallOrUpdate(x); // No need to wait
_ = InstallOrUpdateAsync(x); // No need to wait
return ShouldHideWindow;
},
ContextData = x
Expand Down Expand Up @@ -502,4 +502,4 @@ private bool SameOrLesserPluginVersionExists(string metadataPath)
&& newMetadata.Version.CompareTo(x.Metadata.Version) <= 0);
}
}
}
}
2 changes: 1 addition & 1 deletion Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ await Task.Run(() =>
});
}

private async void LaunchElevated()
private void LaunchElevated()
{
string command = "shell:AppsFolder\\" + UniqueIdentifier;
command = Environment.ExpandEnvironmentVariables(command.Trim());
Expand Down

0 comments on commit 30669e8

Please sign in to comment.