Skip to content

Commit d4f9099

Browse files
committed
Improve constructor injection for updater
1 parent a3964f5 commit d4f9099

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

Flow.Launcher.Core/Updater.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ public class Updater
2424
{
2525
private readonly IPublicAPI API;
2626

27-
public string GitHubRepository { get; set; }
27+
public string GitHubRepository { get; init; }
2828

29-
public Updater(IPublicAPI publicAPI)
29+
public Updater(IPublicAPI publicAPI, string gitHubRepository)
3030
{
3131
API = publicAPI;
32-
}
33-
34-
public void Initialize(string gitHubRepository)
35-
{
3632
GitHubRepository = gitHubRepository;
3733
}
3834

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public App()
4545
.UseContentRoot(AppContext.BaseDirectory)
4646
.ConfigureServices(services => services
4747
.AddSingleton(_ => _settings)
48-
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>()))
48+
.AddSingleton(sp => new Updater(sp.GetRequiredService<IPublicAPI>(), Launcher.Properties.Settings.Default.GithubRepo))
4949
.AddSingleton<Portable>()
5050
.AddSingleton<SettingWindowViewModel>()
5151
.AddSingleton<IAlphabet, PinyinAlphabet>()
@@ -79,8 +79,6 @@ private async void OnStartupAsync(object sender, StartupEventArgs e)
7979
{
8080
await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
8181
{
82-
Ioc.Default.GetRequiredService<Updater>().Initialize(Launcher.Properties.Settings.Default.GithubRepo);
83-
8482
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
8583

8684
Log.Info("|App.OnStartup|Begin Flow Launcher startup ----------------------------------------------------");

0 commit comments

Comments
 (0)