@@ -187,12 +187,14 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
187187 // So set to OnExplicitShutdown to prevent the application from shutting down before main window is created
188188 Current . ShutdownMode = ShutdownMode . OnExplicitShutdown ;
189189
190+ // Setup log level before any logging is done
190191 Log . SetLogLevel ( _settings . LogLevel ) ;
191192
192193 // Update dynamic resources base on settings
193194 Current . Resources [ "SettingWindowFont" ] = new FontFamily ( _settings . SettingWindowFont ) ;
194195 Current . Resources [ "ContentControlThemeFontFamily" ] = new FontFamily ( _settings . SettingWindowFont ) ;
195196
197+ // Initialize notification system before any notification api is called
196198 Notification . Install ( ) ;
197199
198200 // Enable Win32 dark mode if the system is in dark mode before creating all windows
@@ -201,6 +203,7 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
201203 // Initialize language before portable clean up since it needs translations
202204 await _internationalization . InitializeLanguageAsync ( ) ;
203205
206+ // Clean up after portability update
204207 Ioc . Default . GetRequiredService < Portable > ( ) . PreStartCleanUpAfterPortabilityUpdate ( ) ;
205208
206209 API . LogInfo ( ClassName , "Begin Flow Launcher startup ----------------------------------------------------" ) ;
@@ -210,52 +213,66 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
210213 RegisterDispatcherUnhandledException ( ) ;
211214 RegisterTaskSchedulerUnhandledException ( ) ;
212215
213- var imageLoadertask = ImageLoader . InitializeAsync ( ) ;
214-
215- AbstractPluginEnvironment . PreStartPluginExecutablePathUpdate ( _settings ) ;
216-
217- PluginManager . LoadPlugins ( _settings . PluginSettings ) ;
218-
219- // Register ResultsUpdated event after all plugins are loaded
220- Ioc . Default . GetRequiredService < MainViewModel > ( ) . RegisterResultsUpdatedEvent ( ) ;
216+ var imageLoaderTask = ImageLoader . InitializeAsync ( ) ;
221217
222218 Http . Proxy = _settings . Proxy ;
223219
224220 // Initialize plugin manifest before initializing plugins so that they can use the manifest instantly
225221 await API . UpdatePluginManifestAsync ( ) ;
226222
227- await PluginManager . InitializePluginsAsync ( ) ;
228-
229- // Update plugin titles after plugins are initialized with their api instances
230- Internationalization . UpdatePluginMetadataTranslations ( ) ;
231-
232- await imageLoadertask ;
223+ await imageLoaderTask ;
233224
234225 _mainWindow = new MainWindow ( ) ;
235226
236227 Current . MainWindow = _mainWindow ;
237228 Current . MainWindow . Title = Constant . FlowLauncher ;
238229
230+ // Initialize Dialog Jump before hotkey mapper since hotkey mapper will register its hotkey
231+ // Initialize Dialog Jump after main window is created so that it can access main window handle
232+ DialogJump . InitializeDialogJump ( ) ;
233+ DialogJump . SetupDialogJump ( _settings . EnableDialogJump ) ;
234+
239235 // Initialize hotkey mapper instantly after main window is created because
240236 // it will steal focus from main window which causes window hide
241237 HotKeyMapper . Initialize ( ) ;
242238
243239 // Initialize theme for main window
244240 Ioc . Default . GetRequiredService < Theme > ( ) . ChangeTheme ( ) ;
245241
246- DialogJump . InitializeDialogJump ( PluginManager . GetDialogJumpExplorers ( ) , PluginManager . GetDialogJumpDialogs ( ) ) ;
247- DialogJump . SetupDialogJump ( _settings . EnableDialogJump ) ;
248-
249242 Encoding . RegisterProvider ( CodePagesEncodingProvider . Instance ) ;
250243
251244 RegisterExitEvents ( ) ;
252245
253246 AutoStartup ( ) ;
254247 AutoUpdates ( ) ;
255- AutoPluginUpdates ( ) ;
256248
257249 API . SaveAppAllSettings ( ) ;
258- API . LogInfo ( ClassName , "End Flow Launcher startup ----------------------------------------------------" ) ;
250+ API . LogInfo ( ClassName , "End Flow Launcher startup ------------------------------------------------------" ) ;
251+
252+ _ = API . StopwatchLogInfoAsync ( ClassName , "Startup cost" , async ( ) =>
253+ {
254+ API . LogInfo ( ClassName , "Begin plugin initialization ----------------------------------------------------" ) ;
255+
256+ AbstractPluginEnvironment . PreStartPluginExecutablePathUpdate ( _settings ) ;
257+
258+ PluginManager . LoadPlugins ( _settings . PluginSettings ) ;
259+
260+ await PluginManager . InitializePluginsAsync ( _mainVM ) ;
261+
262+ // Refresh home page after plugins are initialized because users may open main window during plugin initialization
263+ // And home page is created without full plugin list
264+ if ( _settings . ShowHomePage && _mainVM . QueryResultsSelected ( ) && string . IsNullOrEmpty ( _mainVM . QueryText ) )
265+ {
266+ _mainVM . QueryResults ( ) ;
267+ }
268+
269+ AutoPluginUpdates ( ) ;
270+
271+ // Save all settings since we possibly update the plugin environment paths
272+ API . SaveAppAllSettings ( ) ;
273+
274+ API . LogInfo ( ClassName , "End plugin initialization ------------------------------------------------------" ) ;
275+ } ) ;
259276 } ) ;
260277 }
261278
0 commit comments