@@ -10,7 +10,6 @@ import {
1010 LibraryService ,
1111 SketchesService ,
1212} from '../common/protocol' ;
13-
1413import {
1514 MAIN_MENU_BAR ,
1615 MenuContribution ,
@@ -51,6 +50,7 @@ import { SaveAsSketch } from './contributions/save-as-sketch';
5150import { ArduinoMenus } from './menu/arduino-menus' ;
5251import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution' ;
5352import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
53+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
5454
5555const INIT_LIBS_AND_PACKAGES = 'initializedLibsAndPackages' ;
5656
@@ -90,6 +90,9 @@ export class ArduinoFrontendContribution
9090 @inject ( LocalStorageService )
9191 private readonly localStorageService : LocalStorageService ;
9292
93+ @inject ( FrontendApplicationStateService )
94+ private readonly appStateService : FrontendApplicationStateService ;
95+
9396 @postConstruct ( )
9497 protected async init ( ) : Promise < void > {
9598 const isFirstStartup = ! ( await this . localStorageService . getData (
@@ -137,17 +140,15 @@ export class ArduinoFrontendContribution
137140 }
138141 }
139142 } ) ;
140-
141- // TODO: Verify this! If true IDE2 can start ~100ms faster.
142- // If the preferences is resolved, then the `ready` call will happen in the same tick
143- // and will do a `send_sync` request to the electron main to get the current window.
144- // Consider moving after app `ready`.
145- this . arduinoPreferences . ready . then ( ( ) => {
146- const webContents = remote . getCurrentWebContents ( ) ;
147- const zoomLevel = this . arduinoPreferences . get ( 'arduino.window.zoomLevel' ) ;
148- webContents . setZoomLevel ( zoomLevel ) ;
149- } ) ;
150-
143+ this . appStateService . reachedState ( 'initialized_layout' ) . then ( ( ) =>
144+ this . arduinoPreferences . ready . then ( ( ) => {
145+ const webContents = remote . getCurrentWebContents ( ) ;
146+ const zoomLevel = this . arduinoPreferences . get (
147+ 'arduino.window.zoomLevel'
148+ ) ;
149+ webContents . setZoomLevel ( zoomLevel ) ;
150+ } )
151+ ) ;
151152 // Removes the _Settings_ (cog) icon from the left sidebar
152153 app . shell . leftPanelHandler . removeBottomMenu ( 'settings-menu' ) ;
153154 }
0 commit comments