From 74ea629c55f81f0c560b567b988d3fd0da2fad66 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 5 Dec 2022 08:46:19 +1100 Subject: [PATCH] search window hides when prompted to install, remove threading --- .../Everything/EverythingDownloadHelper.cs | 23 ++++--------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs index c5ecc250d..ce774281c 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs @@ -13,25 +13,18 @@ public static class EverythingDownloadHelper { public static async Task PromptDownloadIfNotInstallAsync(string installedLocation, IPublicAPI api) { - if (installedLocation.FileExists()) - return installedLocation; - - if (!string.IsNullOrEmpty(installedLocation)) + if (!string.IsNullOrEmpty(installedLocation) && installedLocation.FileExists()) return installedLocation; installedLocation = GetInstalledPath(); if (string.IsNullOrEmpty(installedLocation)) { - // Solves single thread apartment (STA) mode requirement error when using OpenFileDialog - var t = new Thread(() => - { - if (System.Windows.Forms.MessageBox.Show( + if (System.Windows.Forms.MessageBox.Show( string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), api.GetTranslation("flowlauncher_plugin_everything_installing_title"), - System.Windows.Forms.MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes) - return; - + System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) + { var dlg = new System.Windows.Forms.OpenFileDialog { InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) @@ -40,13 +33,7 @@ public static class EverythingDownloadHelper var result = dlg.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dlg.FileName)) installedLocation = dlg.FileName; - - }); - - // Run your code from a thread that joins the STA Thread - t.SetApartmentState(ApartmentState.STA); - t.Start(); - t.Join(); + } } if (!string.IsNullOrEmpty(installedLocation))