diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 1ee033821f0..c8d3ffbc470 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -5,12 +5,10 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using System.Windows.Documents; using System.Windows.Media; using System.Windows.Media.Imaging; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Storage; -using static Flow.Launcher.Infrastructure.Http.Http; namespace Flow.Launcher.Infrastructure.Image { @@ -28,7 +26,6 @@ public static class ImageLoader public const int SmallIconSize = 64; public const int FullIconSize = 256; - private static readonly string[] ImageExtensions = { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" }; public static async Task InitializeAsync() @@ -183,7 +180,7 @@ private static async ValueTask LoadInternalAsync(string path, bool private static async Task LoadRemoteImageAsync(bool loadFullImage, Uri uriResult) { // Download image from url - await using var resp = await GetStreamAsync(uriResult); + await using var resp = await Http.Http.GetStreamAsync(uriResult); await using var buffer = new MemoryStream(); await resp.CopyToAsync(buffer); buffer.Seek(0, SeekOrigin.Begin); diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index f484d4dbadc..81938612c34 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -179,8 +179,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () => Current.MainWindow = _mainWindow; Current.MainWindow.Title = Constant.FlowLauncher; - HotKeyMapper.Initialize(); - // main windows needs initialized before theme change because of blur settings Ioc.Default.GetRequiredService().ChangeTheme(); diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index c62606743a6..30afe67a1f3 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -16,8 +16,10 @@ using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Resource; +using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; +using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.ViewModel; @@ -173,6 +175,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _) // Without this part, when shown for the first time, switching the context menu does not move the cursor to the end. _viewModel.QueryTextCursorMovedToEnd = false; + // Initialize hotkey mapper after window is loaded + HotKeyMapper.Initialize(); + // View model property changed event _viewModel.PropertyChanged += (o, e) => { @@ -289,6 +294,7 @@ private async void OnClosing(object sender, CancelEventArgs e) _notifyIcon.Visible = false; App.API.SaveAppAllSettings(); e.Cancel = true; + await ImageLoader.WaitSaveAsync(); await PluginManager.DisposePluginsAsync(); Notification.Uninstall(); // After plugins are all disposed, we can close the main window