1+ import { nls } from '@theia/core/lib/common/nls' ;
12import { inject , injectable } from '@theia/core/shared/inversify' ;
2- import { nls } from '@theia/core/lib/common' ;
33import { BoardUserField , CoreError } from '../../common/protocol' ;
44import { BoardsServiceProvider } from '../boards/boards-service-provider' ;
55import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog' ;
66import { ArduinoMenus } from '../menu/arduino-menus' ;
7- import { MenuModelRegistry , Contribution } from './contribution' ;
7+ import { Contribution , MenuModelRegistry } from './contribution' ;
88import { UploadSketch } from './upload-sketch' ;
99
1010@injectable ( )
@@ -21,12 +21,11 @@ export class UserFields extends Contribution {
2121
2222 protected override init ( ) : void {
2323 super . init ( ) ;
24- this . boardsServiceProvider . onBoardsConfigDidChange ( async ( ) => {
25- const userFields =
26- await this . boardsServiceProvider . selectedBoardUserFields ( ) ;
27- this . boardRequiresUserFields = userFields . length > 0 ;
28- this . menuManager . update ( ) ;
29- } ) ;
24+ this . boardsServiceProvider . onBoardsConfigDidChange ( ( ) => this . refresh ( ) ) ;
25+ }
26+
27+ override onReady ( ) : void {
28+ this . boardsServiceProvider . ready . then ( ( ) => this . refresh ( ) ) ;
3029 }
3130
3231 override registerMenus ( registry : MenuModelRegistry ) : void {
@@ -37,6 +36,13 @@ export class UserFields extends Contribution {
3736 } ) ;
3837 }
3938
39+ private async refresh ( ) : Promise < void > {
40+ const userFields =
41+ await this . boardsServiceProvider . selectedBoardUserFields ( ) ;
42+ this . boardRequiresUserFields = userFields . length > 0 ;
43+ this . menuManager . update ( ) ;
44+ }
45+
4046 private selectedFqbnAddress ( ) : string | undefined {
4147 const { boardsConfig } = this . boardsServiceProvider ;
4248 const fqbn = boardsConfig . selectedBoard ?. fqbn ;
0 commit comments