Skip to content

Commit 75ca537

Browse files
authored
Merge pull request #3422 from Flow-Launcher/wait_window_initialization
Initialize HotKeyMapper after window is loaded & Wait image cache saved before closing main window
2 parents 4eba415 + 08230df commit 75ca537

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

Flow.Launcher.Infrastructure/Image/ImageLoader.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
using System.Linq;
66
using System.Threading;
77
using System.Threading.Tasks;
8-
using System.Windows.Documents;
98
using System.Windows.Media;
109
using System.Windows.Media.Imaging;
1110
using Flow.Launcher.Infrastructure.Logger;
1211
using Flow.Launcher.Infrastructure.Storage;
13-
using static Flow.Launcher.Infrastructure.Http.Http;
1412

1513
namespace Flow.Launcher.Infrastructure.Image
1614
{
@@ -28,7 +26,6 @@ public static class ImageLoader
2826
public const int SmallIconSize = 64;
2927
public const int FullIconSize = 256;
3028

31-
3229
private static readonly string[] ImageExtensions = { ".png", ".jpg", ".jpeg", ".gif", ".bmp", ".tiff", ".ico" };
3330

3431
public static async Task InitializeAsync()
@@ -183,7 +180,7 @@ private static async ValueTask<ImageResult> LoadInternalAsync(string path, bool
183180
private static async Task<BitmapImage> LoadRemoteImageAsync(bool loadFullImage, Uri uriResult)
184181
{
185182
// Download image from url
186-
await using var resp = await GetStreamAsync(uriResult);
183+
await using var resp = await Http.Http.GetStreamAsync(uriResult);
187184
await using var buffer = new MemoryStream();
188185
await resp.CopyToAsync(buffer);
189186
buffer.Seek(0, SeekOrigin.Begin);

Flow.Launcher/App.xaml.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
179179
Current.MainWindow = _mainWindow;
180180
Current.MainWindow.Title = Constant.FlowLauncher;
181181

182-
HotKeyMapper.Initialize();
183-
184182
// main windows needs initialized before theme change because of blur settings
185183
Ioc.Default.GetRequiredService<Theme>().ChangeTheme();
186184

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
using CommunityToolkit.Mvvm.DependencyInjection;
1717
using Flow.Launcher.Core.Plugin;
1818
using Flow.Launcher.Core.Resource;
19+
using Flow.Launcher.Helper;
1920
using Flow.Launcher.Infrastructure;
2021
using Flow.Launcher.Infrastructure.Hotkey;
22+
using Flow.Launcher.Infrastructure.Image;
2123
using Flow.Launcher.Infrastructure.UserSettings;
2224
using Flow.Launcher.Plugin.SharedCommands;
2325
using Flow.Launcher.ViewModel;
@@ -173,6 +175,9 @@ private async void OnLoaded(object sender, RoutedEventArgs _)
173175
// Without this part, when shown for the first time, switching the context menu does not move the cursor to the end.
174176
_viewModel.QueryTextCursorMovedToEnd = false;
175177

178+
// Initialize hotkey mapper after window is loaded
179+
HotKeyMapper.Initialize();
180+
176181
// View model property changed event
177182
_viewModel.PropertyChanged += (o, e) =>
178183
{
@@ -289,6 +294,7 @@ private async void OnClosing(object sender, CancelEventArgs e)
289294
_notifyIcon.Visible = false;
290295
App.API.SaveAppAllSettings();
291296
e.Cancel = true;
297+
await ImageLoader.WaitSaveAsync();
292298
await PluginManager.DisposePluginsAsync();
293299
Notification.Uninstall();
294300
// After plugins are all disposed, we can close the main window

0 commit comments

Comments
 (0)