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)
|
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
|
// We should not initialize API in static constructor because it will create another API instance
|
||||||
private static IPublicAPI api = null;
|
private static IPublicAPI api = null;
|
||||||
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
private static IPublicAPI API => api ??= Ioc.Default.GetRequiredService<IPublicAPI>();
|
||||||
|
|
||||||
private static readonly string ClassName = nameof(CommunityPluginSource);
|
|
||||||
|
|
||||||
private string latestEtag = "";
|
private string latestEtag = "";
|
||||||
|
|
||||||
private List<UserPlugin> plugins = new();
|
private List<UserPlugin> plugins = new();
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
API.LogWarn(ClassName, $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
API.LogWarn(ClassName, $"Failed to load resource {ManifestFileUrl} with response {response.StatusCode}");
|
||||||
return plugins;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -83,7 +83,7 @@ namespace Flow.Launcher.Core.ExternalPlugins
|
||||||
{
|
{
|
||||||
API.LogException(ClassName, "Error Occurred", e);
|
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);
|
var completedTask = await Task.WhenAny(tasks);
|
||||||
if (completedTask.IsCompletedSuccessfully)
|
if (completedTask.IsCompletedSuccessfully)
|
||||||
{
|
{
|
||||||
// one of the requests completed successfully; keep its results
|
var result = await completedTask;
|
||||||
// and cancel the remaining http requests.
|
if (result != null)
|
||||||
pluginResults = await completedTask;
|
{
|
||||||
cts.Cancel();
|
// one of the requests completed successfully; keep its results
|
||||||
|
// and cancel the remaining http requests.
|
||||||
|
pluginResults = result;
|
||||||
|
cts.Cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tasks.Remove(completedTask);
|
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
|
// we try to enable auto-startup on first launch, or reenable if it was removed
|
||||||
// but the user still has the setting set
|
// but the user still has the setting set
|
||||||
if (_settings.StartFlowLauncherOnSystemStartup && !Helper.AutoStartup.IsEnabled)
|
if (_settings.StartFlowLauncherOnSystemStartup)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_settings.UseLogonTaskForStartup)
|
Helper.AutoStartup.CheckIsEnabled(_settings.UseLogonTaskForStartup);
|
||||||
{
|
|
||||||
Helper.AutoStartup.EnableViaLogonTask();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Helper.AutoStartup.EnableViaRegistry();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using Flow.Launcher.Infrastructure;
|
using Flow.Launcher.Infrastructure;
|
||||||
using Flow.Launcher.Infrastructure.Logger;
|
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Microsoft.Win32.TaskScheduler;
|
using Microsoft.Win32.TaskScheduler;
|
||||||
|
|
||||||
|
|
@ -17,29 +16,37 @@ public class AutoStartup
|
||||||
private const string LogonTaskName = $"{Constant.FlowLauncher} Startup";
|
private const string LogonTaskName = $"{Constant.FlowLauncher} Startup";
|
||||||
private const string LogonTaskDesc = $"{Constant.FlowLauncher} Auto 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
|
// Enable logon task
|
||||||
if (CheckLogonTask())
|
if (!logonTaskEnabled)
|
||||||
{
|
{
|
||||||
return true;
|
Enable(true);
|
||||||
}
|
}
|
||||||
|
// Disable registry
|
||||||
// Check if registry is enabled
|
if (registryEnabled)
|
||||||
try
|
|
||||||
{
|
{
|
||||||
using var key = Registry.CurrentUser.OpenSubKey(StartupPath, true);
|
Disable(false);
|
||||||
var path = key?.GetValue(Constant.FlowLauncher) as string;
|
|
||||||
return path == Constant.ExecutablePath;
|
|
||||||
}
|
}
|
||||||
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;
|
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()
|
public static void DisableViaLogonTaskAndRegistry()
|
||||||
{
|
{
|
||||||
Disable(true);
|
Disable(true);
|
||||||
Disable(false);
|
Disable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void EnableViaLogonTask()
|
|
||||||
{
|
|
||||||
Enable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void EnableViaRegistry()
|
|
||||||
{
|
|
||||||
Enable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ChangeToViaLogonTask()
|
public static void ChangeToViaLogonTask()
|
||||||
{
|
{
|
||||||
Disable(false);
|
Disable(false);
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using NHotkey;
|
||||||
using NHotkey.Wpf;
|
using NHotkey.Wpf;
|
||||||
using Flow.Launcher.ViewModel;
|
using Flow.Launcher.ViewModel;
|
||||||
using ChefKeys;
|
using ChefKeys;
|
||||||
using Flow.Launcher.Infrastructure.Logger;
|
|
||||||
using CommunityToolkit.Mvvm.DependencyInjection;
|
using CommunityToolkit.Mvvm.DependencyInjection;
|
||||||
|
|
||||||
namespace Flow.Launcher.Helper;
|
namespace Flow.Launcher.Helper;
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,11 @@ public partial class SettingsPaneGeneralViewModel : BaseModel
|
||||||
{
|
{
|
||||||
if (UseLogonTaskForStartup)
|
if (UseLogonTaskForStartup)
|
||||||
{
|
{
|
||||||
AutoStartup.EnableViaLogonTask();
|
AutoStartup.ChangeToViaLogonTask();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AutoStartup.EnableViaRegistry();
|
AutoStartup.ChangeToViaRegistry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue