Skip to content

Commit ed39937

Browse files
committed
Initialize App.API earlier & Improve code quality
1 parent cdc5f0e commit ed39937

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
7070
).Build();
7171
Ioc.Default.ConfigureServices(host.Services);
7272

73+
API = Ioc.Default.GetRequiredService<IPublicAPI>();
74+
7375
Ioc.Default.GetRequiredService<Updater>().Initialize(Launcher.Properties.Settings.Default.GithubRepo);
7476

7577
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
@@ -93,9 +95,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
9395

9496
PluginManager.LoadPlugins(_settings.PluginSettings);
9597

96-
API = Ioc.Default.GetRequiredService<IPublicAPI>();
97-
((PublicAPIInstance)API).Initialize();
98-
9998
Http.API = API;
10099
Http.Proxy = _settings.Proxy;
101100

Flow.Launcher/PublicAPIInstance.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ public class PublicAPIInstance : IPublicAPI
3535
private readonly SettingWindowViewModel _settingsVM;
3636
private readonly MainViewModel _mainVM;
3737

38-
private Updater _updater;
39-
40-
#region Constructor & Initialization
38+
#region Constructor
4139

4240
public PublicAPIInstance()
4341
{
@@ -47,13 +45,6 @@ public PublicAPIInstance()
4745
WebRequest.RegisterPrefix("data", new DataWebRequestFactory());
4846
}
4947

50-
public void Initialize()
51-
{
52-
// We need to initialize Updater not in the constructor because we want to avoid
53-
// recrusive dependency injection
54-
_updater = Ioc.Default.GetRequiredService<Updater>();
55-
}
56-
5748
#endregion
5849

5950
#region Public API
@@ -86,7 +77,7 @@ public void RestartApp()
8677

8778
public event VisibilityChangedEventHandler VisibilityChanged { add => _mainVM.VisibilityChanged += value; remove => _mainVM.VisibilityChanged -= value; }
8879

89-
public void CheckForNewUpdate() => _ = _updater.UpdateAppAsync(false);
80+
public void CheckForNewUpdate() => _ = Ioc.Default.GetRequiredService<Updater>().UpdateAppAsync(false);
9081

9182
public void SaveAppAllSettings()
9283
{

0 commit comments

Comments
 (0)