Skip to content

Commit 86581e6

Browse files
committed
Add disposable for internalization
1 parent 330e6c0 commit 86581e6

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Flow.Launcher.Core.Resource
1616
{
17-
public class Internationalization
17+
public class Internationalization : IDisposable
1818
{
1919
private static readonly string ClassName = nameof(Internationalization);
2020

@@ -379,5 +379,15 @@ public static void UpdatePluginMetadataTranslations()
379379
}
380380

381381
#endregion
382+
383+
#region IDisposable
384+
385+
public void Dispose()
386+
{
387+
RemoveOldLanguageFiles();
388+
_langChangeLock.Dispose();
389+
}
390+
391+
#endregion
382392
}
383393
}

Flow.Launcher/App.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public partial class App : IDisposable, ISingleInstanceApp
4545
private static Settings _settings;
4646
private static MainWindow _mainWindow;
4747
private readonly MainViewModel _mainVM;
48+
private readonly Internationalization _internationalization;
4849

4950
// To prevent two disposals running at the same time.
5051
private static readonly object _disposingLock = new();
@@ -107,6 +108,7 @@ public App()
107108
API = Ioc.Default.GetRequiredService<IPublicAPI>();
108109
_settings.Initialize();
109110
_mainVM = Ioc.Default.GetRequiredService<MainViewModel>();
111+
_internationalization = Ioc.Default.GetRequiredService<Internationalization>();
110112
}
111113
catch (Exception e)
112114
{
@@ -193,7 +195,7 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
193195
Win32Helper.EnableWin32DarkMode(_settings.ColorScheme);
194196

195197
// Initialize language before portable clean up since it needs translations
196-
await Ioc.Default.GetRequiredService<Internationalization>().InitializeLanguageAsync();
198+
await _internationalization.InitializeLanguageAsync();
197199

198200
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
199201

@@ -421,6 +423,7 @@ protected virtual void Dispose(bool disposing)
421423
_mainWindow?.Dispatcher.Invoke(_mainWindow.Dispose);
422424
_mainVM?.Dispose();
423425
DialogJump.Dispose();
426+
_internationalization.Dispose();
424427
}
425428

426429
API.LogInfo(ClassName, "End Flow Launcher dispose ----------------------------------------------------");

0 commit comments

Comments
 (0)