mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #3472 from Flow-Launcher/startup_window_popup
Fix Possible Window Popup During Startup & Fix Store Plugin List Refresh Issue
This commit is contained in:
commit
d30fdbb527
6 changed files with 55 additions and 46 deletions
|
|
@ -16,12 +16,12 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
{
|
||||
public record CommunityPluginSource(string ManifestFileUrl)
|
||||
{
|
||||
private static readonly string ClassName = nameof(CommunityPluginSource);
|
||||
|
||||
// We should not initialize API in static constructor because it will create another API instance
|
||||
private static IPublicAPI api = null;
|
||||
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
||||
|
||||
private static readonly string ClassName = nameof(CommunityPluginSource);
|
||||
|
||||
private string latestEtag = "";
|
||||
|
||||
private List<UserPlugin> plugins = new();
|
||||
|
|
@ -70,7 +70,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
else
|
||||
{
|
||||
API.LogWarn(ClassName, $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
||||
return plugins;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -83,7 +83,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
{
|
||||
API.LogException(ClassName, "Error Occurred", e);
|
||||
}
|
||||
return plugins;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,10 +40,14 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
|||
var completedTask = await Task.WhenAny(tasks);
|
||||
if (completedTask.IsCompletedSuccessfully)
|
||||
{
|
||||
// one of the requests completed successfully; keep its results
|
||||
// and cancel the remaining http requests.
|
||||
pluginResults = await completedTask;
|
||||
cts.Cancel();
|
||||
var result = await completedTask;
|
||||
if (result != null)
|
||||
{
|
||||
// one of the requests completed successfully; keep its results
|
||||
// and cancel the remaining http requests.
|
||||
pluginResults = result;
|
||||
cts.Cancel();
|
||||
}
|
||||
}
|
||||
tasks.Remove(completedTask);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -202,18 +202,11 @@ namespace Flow.Launcher
|
|||
{
|
||||
// we try to enable auto-startup on first launch, or reenable if it was removed
|
||||
// but the user still has the setting set
|
||||
if (_settings.StartFlowLauncherOnSystemStartup && !Helper.AutoStartup.IsEnabled)
|
||||
if (_settings.StartFlowLauncherOnSystemStartup)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_settings.UseLogonTaskForStartup)
|
||||
{
|
||||
Helper.AutoStartup.EnableViaLogonTask();
|
||||
}
|
||||
else
|
||||
{
|
||||
Helper.AutoStartup.EnableViaRegistry();
|
||||
}
|
||||
Helper.AutoStartup.CheckIsEnabled(_settings.UseLogonTaskForStartup);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using Flow.Launcher.Infrastructure;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using Microsoft.Win32;
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
|
||||
|
|
@ -17,29 +16,37 @@ public class AutoStartup
|
|||
private const string LogonTaskName = $"{Constant.FlowLauncher} Startup";
|
||||
private const string LogonTaskDesc = $"{Constant.FlowLauncher} Auto Startup";
|
||||
|
||||
public static bool IsEnabled
|
||||
public static void CheckIsEnabled(bool useLogonTaskForStartup)
|
||||
{
|
||||
get
|
||||
// We need to check both because if both of them are enabled,
|
||||
// Hide Flow Launcher on startup will not work since the later one will trigger main window show event
|
||||
var logonTaskEnabled = CheckLogonTask();
|
||||
var registryEnabled = CheckRegistry();
|
||||
if (useLogonTaskForStartup)
|
||||
{
|
||||
// Check if logon task is enabled
|
||||
if (CheckLogonTask())
|
||||
// Enable logon task
|
||||
if (!logonTaskEnabled)
|
||||
{
|
||||
return true;
|
||||
Enable(true);
|
||||
}
|
||||
|
||||
// Check if registry is enabled
|
||||
try
|
||||
// Disable registry
|
||||
if (registryEnabled)
|
||||
{
|
||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
||||
var path = key?.GetValue(Constant.FlowLauncher) as string;
|
||||
return path == Constant.ExecutablePath;
|
||||
Disable(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Enable registry
|
||||
if (!registryEnabled)
|
||||
{
|
||||
App.API.LogError(ClassName, $"Ignoring non-critical registry error (querying if enabled): {e}");
|
||||
Enable(false);
|
||||
}
|
||||
// Disable logon task
|
||||
if (logonTaskEnabled)
|
||||
{
|
||||
Disable(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -70,22 +77,28 @@ public class AutoStartup
|
|||
return false;
|
||||
}
|
||||
|
||||
private static bool CheckRegistry()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
||||
var path = key?.GetValue(Constant.FlowLauncher) as string;
|
||||
return path == Constant.ExecutablePath;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.API.LogError(ClassName, $"Ignoring non-critical registry error (querying if enabled): {e}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void DisableViaLogonTaskAndRegistry()
|
||||
{
|
||||
Disable(true);
|
||||
Disable(false);
|
||||
}
|
||||
|
||||
public static void EnableViaLogonTask()
|
||||
{
|
||||
Enable(true);
|
||||
}
|
||||
|
||||
public static void EnableViaRegistry()
|
||||
{
|
||||
Enable(false);
|
||||
}
|
||||
|
||||
public static void ChangeToViaLogonTask()
|
||||
{
|
||||
Disable(false);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using NHotkey;
|
|||
using NHotkey.Wpf;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using ChefKeys;
|
||||
using Flow.Launcher.Infrastructure.Logger;
|
||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||
|
||||
namespace Flow.Launcher.Helper;
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
|||
{
|
||||
if (UseLogonTaskForStartup)
|
||||
{
|
||||
AutoStartup.EnableViaLogonTask();
|
||||
AutoStartup.ChangeToViaLogonTask();
|
||||
}
|
||||
else
|
||||
{
|
||||
AutoStartup.EnableViaRegistry();
|
||||
AutoStartup.ChangeToViaRegistry();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue