Skip to content

Commit 8f93cf4

Browse files
author
Akos Kitta
committed
set zoom level after layout initialization.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent f5a1f9e commit 8f93cf4

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

arduino-ide-extension/src/browser/arduino-frontend-contribution.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '@theia/core/shared/inversify';
77
import * as React from '@theia/core/shared/react';
88
import { SketchesService } from '../common/protocol';
9-
109
import {
1110
MAIN_MENU_BAR,
1211
MenuContribution,
@@ -46,6 +45,7 @@ import { SaveAsSketch } from './contributions/save-as-sketch';
4645
import { ArduinoMenus } from './menu/arduino-menus';
4746
import { MonitorViewContribution } from './serial/monitor/monitor-view-contribution';
4847
import { ArduinoToolbar } from './toolbar/arduino-toolbar';
48+
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
4949

5050
export const SKIP_IDE_VERSION = 'skipIDEVersion';
5151

@@ -76,6 +76,9 @@ export class ArduinoFrontendContribution
7676
@inject(SketchesServiceClientImpl)
7777
private readonly sketchServiceClient: SketchesServiceClientImpl;
7878

79+
@inject(FrontendApplicationStateService)
80+
private readonly appStateService: FrontendApplicationStateService;
81+
7982
@postConstruct()
8083
protected async init(): Promise<void> {
8184
if (!window.navigator.onLine) {
@@ -102,17 +105,15 @@ export class ArduinoFrontendContribution
102105
}
103106
}
104107
});
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+
);
116117
// Removes the _Settings_ (cog) icon from the left sidebar
117118
app.shell.leftPanelHandler.removeBottomMenu('settings-menu');
118119
}

0 commit comments

Comments
 (0)