From d4f90999c76ae3467c55fc71fda0aa4cb14d8e96 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 23 Feb 2025 13:55:33 +0800 Subject: [PATCH] Improve constructor injection for updater --- Flow.Launcher.Core/Updater.cs | 8 ++------ Flow.Launcher/App.xaml.cs | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 073084e4d..43d86a487 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -24,15 +24,11 @@ namespace Flow.Launcher.Core { private readonly IPublicAPI API; - public string GitHubRepository { get; set; } + public string GitHubRepository { get; init; } - public Updater(IPublicAPI publicAPI) + public Updater(IPublicAPI publicAPI, string gitHubRepository) { API = publicAPI; - } - - public void Initialize(string gitHubRepository) - { GitHubRepository = gitHubRepository; } diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index c5fe3159f..67e536b1b 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -45,7 +45,7 @@ namespace Flow.Launcher .UseContentRoot(AppContext.BaseDirectory) .ConfigureServices(services => services .AddSingleton(_ => _settings) - .AddSingleton(sp => new Updater(sp.GetRequiredService())) + .AddSingleton(sp => new Updater(sp.GetRequiredService(), Launcher.Properties.Settings.Default.GithubRepo)) .AddSingleton() .AddSingleton() .AddSingleton() @@ -79,8 +79,6 @@ namespace Flow.Launcher { await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => { - Ioc.Default.GetRequiredService().Initialize(Launcher.Properties.Settings.Default.GithubRepo); - Ioc.Default.GetRequiredService().PreStartCleanUpAfterPortabilityUpdate(); Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");