Improve constructor injection for updater

This commit is contained in:
Jack251970 2025-02-23 13:55:33 +08:00
parent a3964f5667
commit d4f90999c7
2 changed files with 3 additions and 9 deletions

View file

@ -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;
}

View file

@ -45,7 +45,7 @@ namespace Flow.Launcher
.UseContentRoot(AppContext.BaseDirectory)
.ConfigureServices(services => services
.AddSingleton(_ => _settings)
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>()))
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo))
.AddSingleton<Portable>()
.AddSingleton<SettingWindowViewModel>()
.AddSingleton<IAlphabet, PinyinAlphabet>()
@ -79,8 +79,6 @@ namespace Flow.Launcher
{
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
{
Ioc.Default.GetRequiredService<Updater>().Initialize(Launcher.Properties.Settings.Default.GithubRepo);
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");