Skip to content

Commit

Permalink
fix: refresh the user-fields at app startup
Browse files Browse the repository at this point in the history
Ref: #2165
Closes #2230

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta committed Sep 21, 2023
1 parent 73ddbef commit 83980b3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions arduino-ide-extension/src/browser/contributions/user-fields.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit 83980b3

Please sign in to comment.