mirror of
				https://github.com/arduino/arduino-ide.git
				synced 2025-11-03 23:48:32 +00:00 
			
		
		
		
	fix: refresh the user-fields at app startup
Ref: arduino/arduino-ide#2165 Closes arduino/arduino-ide#2230 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
		@@ -1,10 +1,10 @@
 | 
			
		||||
import { nls } from '@theia/core/lib/common/nls';
 | 
			
		||||
import { inject, injectable } from '@theia/core/shared/inversify';
 | 
			
		||||
import { nls } from '@theia/core/lib/common';
 | 
			
		||||
import { BoardUserField, CoreError } from '../../common/protocol';
 | 
			
		||||
import { BoardsServiceProvider } from '../boards/boards-service-provider';
 | 
			
		||||
import { UserFieldsDialog } from '../dialogs/user-fields/user-fields-dialog';
 | 
			
		||||
import { ArduinoMenus } from '../menu/arduino-menus';
 | 
			
		||||
import { MenuModelRegistry, Contribution } from './contribution';
 | 
			
		||||
import { Contribution, MenuModelRegistry } from './contribution';
 | 
			
		||||
import { UploadSketch } from './upload-sketch';
 | 
			
		||||
 | 
			
		||||
@injectable()
 | 
			
		||||
@@ -21,12 +21,11 @@ export class UserFields extends Contribution {
 | 
			
		||||
 | 
			
		||||
  protected override init(): void {
 | 
			
		||||
    super.init();
 | 
			
		||||
    this.boardsServiceProvider.onBoardsConfigDidChange(async () => {
 | 
			
		||||
      const userFields =
 | 
			
		||||
        await this.boardsServiceProvider.selectedBoardUserFields();
 | 
			
		||||
      this.boardRequiresUserFields = userFields.length > 0;
 | 
			
		||||
      this.menuManager.update();
 | 
			
		||||
    });
 | 
			
		||||
    this.boardsServiceProvider.onBoardsConfigDidChange(() => this.refresh());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  override onReady(): void {
 | 
			
		||||
    this.boardsServiceProvider.ready.then(() => this.refresh());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  override registerMenus(registry: MenuModelRegistry): void {
 | 
			
		||||
@@ -37,6 +36,13 @@ export class UserFields extends Contribution {
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private async refresh(): Promise<void> {
 | 
			
		||||
    const userFields =
 | 
			
		||||
      await this.boardsServiceProvider.selectedBoardUserFields();
 | 
			
		||||
    this.boardRequiresUserFields = userFields.length > 0;
 | 
			
		||||
    this.menuManager.update();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private selectedFqbnAddress(): string | undefined {
 | 
			
		||||
    const { boardsConfig } = this.boardsServiceProvider;
 | 
			
		||||
    const fqbn = boardsConfig.selectedBoard?.fqbn;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user