6
6
} from '@theia/core/shared/inversify' ;
7
7
import * as React from '@theia/core/shared/react' ;
8
8
import { SketchesService } from '../common/protocol' ;
9
-
10
9
import {
11
10
MAIN_MENU_BAR ,
12
11
MenuContribution ,
@@ -46,6 +45,7 @@ import { SaveAsSketch } from './contributions/save-as-sketch';
46
45
import { ArduinoMenus } from './menu/arduino-menus' ;
47
46
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution' ;
48
47
import { ArduinoToolbar } from './toolbar/arduino-toolbar' ;
48
+ import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
49
49
50
50
export const SKIP_IDE_VERSION = 'skipIDEVersion' ;
51
51
@@ -76,6 +76,9 @@ export class ArduinoFrontendContribution
76
76
@inject ( SketchesServiceClientImpl )
77
77
private readonly sketchServiceClient : SketchesServiceClientImpl ;
78
78
79
+ @inject ( FrontendApplicationStateService )
80
+ private readonly appStateService : FrontendApplicationStateService ;
81
+
79
82
@postConstruct ( )
80
83
protected async init ( ) : Promise < void > {
81
84
if ( ! window . navigator . onLine ) {
@@ -102,17 +105,15 @@ export class ArduinoFrontendContribution
102
105
}
103
106
}
104
107
} ) ;
105
-
106
- // TODO: Verify this! If true IDE2 can start ~100ms faster.
107
- // If the preferences is resolved, then the `ready` call will happen in the same tick
108
- // and will do a `send_sync` request to the electron main to get the current window.
109
- // Consider moving after app `ready`.
110
- this . arduinoPreferences . ready . then ( ( ) => {
111
- const webContents = remote . getCurrentWebContents ( ) ;
112
- const zoomLevel = this . arduinoPreferences . get ( 'arduino.window.zoomLevel' ) ;
113
- webContents . setZoomLevel ( zoomLevel ) ;
114
- } ) ;
115
-
108
+ this . appStateService . reachedState ( 'initialized_layout' ) . then ( ( ) =>
109
+ this . arduinoPreferences . ready . then ( ( ) => {
110
+ const webContents = remote . getCurrentWebContents ( ) ;
111
+ const zoomLevel = this . arduinoPreferences . get (
112
+ 'arduino.window.zoomLevel'
113
+ ) ;
114
+ webContents . setZoomLevel ( zoomLevel ) ;
115
+ } )
116
+ ) ;
116
117
// Removes the _Settings_ (cog) icon from the left sidebar
117
118
app . shell . leftPanelHandler . removeBottomMenu ( 'settings-menu' ) ;
118
119
}
0 commit comments