From afba3c01cc145646cf887a0c8b4f3406725f8d6d Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Apr 2025 12:52:26 +0800 Subject: [PATCH 1/5] Initialize hotkey mapper after window is loaded --- Flow.Launcher/App.xaml.cs | 2 -- Flow.Launcher/MainWindow.xaml.cs | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) 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..6173fd8cec6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -173,6 +173,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 shown or hiden the first it is loaded + HotKeyMapper.Initialize(); + // View model property changed event _viewModel.PropertyChanged += (o, e) => { From 4affbe3d0159e07a4ebefe4bad1d20426112475c Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Apr 2025 13:04:37 +0800 Subject: [PATCH 2/5] Wait image cache storage --- Flow.Launcher/MainWindow.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 6173fd8cec6..ccb8d4db6c7 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -18,6 +18,7 @@ using Flow.Launcher.Core.Resource; 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; @@ -292,6 +293,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 From a3ea61589d2424dd5461c25234636d9912f12d09 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Apr 2025 13:05:04 +0800 Subject: [PATCH 3/5] Fix build issue --- Flow.Launcher/MainWindow.xaml.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index ccb8d4db6c7..29b4c203f85 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -16,6 +16,7 @@ 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; From 7723c4454b8321fd120e7c347692172d56dff6f0 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Apr 2025 13:08:39 +0800 Subject: [PATCH 4/5] Improve code comments --- Flow.Launcher/MainWindow.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 29b4c203f85..30afe67a1f3 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -175,7 +175,7 @@ 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 shown or hiden the first it is loaded + // Initialize hotkey mapper after window is loaded HotKeyMapper.Initialize(); // View model property changed event From 08230df5c7aa7e062d1760595577e9c1c4bbd552 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sat, 5 Apr 2025 16:38:06 +0800 Subject: [PATCH 5/5] Code quality --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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);