Skip to content

fix: use board+port at startup if it's restored #2242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions arduino-ide-extension/src/browser/contributions/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SketchContribution,
TabBarToolbarRegistry,
} from './contribution';
import { MaybePromise, MenuModelRegistry, nls } from '@theia/core/lib/common';
import { MenuModelRegistry, nls } from '@theia/core/lib/common';
import { CurrentSketch } from '../sketches-service-client-impl';
import { ArduinoMenus } from '../menu/arduino-menus';

Expand Down Expand Up @@ -99,8 +99,8 @@ export class Debug extends SketchContribution {
this.notificationCenter.onPlatformDidUninstall(() => this.refreshState());
}

override onReady(): MaybePromise<void> {
this.refreshState();
override onReady(): void {
this.boardsServiceProvider.ready.then(() => this.refreshState());
}

override registerCommands(registry: CommandRegistry): void {
Expand Down
4 changes: 2 additions & 2 deletions arduino-ide-extension/src/browser/contributions/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ export class LibraryExamples extends Examples {
this.notificationCenter.onLibraryDidUninstall(() => this.update());
}

override async onReady(): Promise<void> {
this.update(); // no `await`
override onReady(): void {
this.boardsServiceProvider.ready.then(() => this.update());
}

protected override handleBoardChanged(board: Board | undefined): void {
Expand Down
30 changes: 13 additions & 17 deletions arduino-ide-extension/src/browser/contributions/include-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import PQueue from 'p-queue';
import { inject, injectable } from '@theia/core/shared/inversify';
import URI from '@theia/core/lib/common/uri';
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { EditorManager } from '@theia/editor/lib/browser';
import { MenuModelRegistry, MenuPath } from '@theia/core/lib/common/menu';
import {
Disposable,
Expand All @@ -22,28 +21,25 @@ import { CurrentSketch } from '../sketches-service-client-impl';
@injectable()
export class IncludeLibrary extends SketchContribution {
@inject(CommandRegistry)
protected readonly commandRegistry: CommandRegistry;
private readonly commandRegistry: CommandRegistry;

@inject(MenuModelRegistry)
protected readonly menuRegistry: MenuModelRegistry;
private readonly menuRegistry: MenuModelRegistry;

@inject(MainMenuManager)
protected readonly mainMenuManager: MainMenuManager;

@inject(EditorManager)
protected override readonly editorManager: EditorManager;
private readonly mainMenuManager: MainMenuManager;

@inject(NotificationCenter)
protected readonly notificationCenter: NotificationCenter;
private readonly notificationCenter: NotificationCenter;

@inject(BoardsServiceProvider)
protected readonly boardsServiceProvider: BoardsServiceProvider;
private readonly boardsServiceProvider: BoardsServiceProvider;

@inject(LibraryService)
protected readonly libraryService: LibraryService;
private readonly libraryService: LibraryService;

protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
protected readonly toDispose = new DisposableCollection();
private readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
private readonly toDispose = new DisposableCollection();

override onStart(): void {
this.boardsServiceProvider.onBoardsConfigDidChange(() =>
Expand All @@ -56,8 +52,8 @@ export class IncludeLibrary extends SketchContribution {
this.notificationCenter.onDidReinitialize(() => this.updateMenuActions());
}

override async onReady(): Promise<void> {
this.updateMenuActions();
override onReady(): void {
this.boardsServiceProvider.ready.then(() => this.updateMenuActions());
}

override registerMenus(registry: MenuModelRegistry): void {
Expand Down Expand Up @@ -93,7 +89,7 @@ export class IncludeLibrary extends SketchContribution {
});
}

protected async updateMenuActions(): Promise<void> {
private async updateMenuActions(): Promise<void> {
return this.queue.add(async () => {
this.toDispose.dispose();
this.mainMenuManager.update();
Expand Down Expand Up @@ -139,7 +135,7 @@ export class IncludeLibrary extends SketchContribution {
});
}

protected registerLibrary(
private registerLibrary(
libraryOrPlaceholder: LibraryPackage | string,
menuPath: MenuPath
): Disposable {
Expand Down Expand Up @@ -172,7 +168,7 @@ export class IncludeLibrary extends SketchContribution {
);
}

protected async includeLibrary(library: LibraryPackage): Promise<void> {
private async includeLibrary(library: LibraryPackage): Promise<void> {
const sketch = await this.sketchServiceClient.currentSketch();
if (!CurrentSketch.isValid(sketch)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ export class SelectedBoard extends Contribution {
private readonly boardsServiceProvider: BoardsServiceProvider;

override onStart(): void {
this.boardsServiceProvider.onBoardListDidChange(() =>
this.update(this.boardsServiceProvider.boardList)
this.boardsServiceProvider.onBoardListDidChange((boardList) =>
this.update(boardList)
);
}

override onReady(): void {
this.update(this.boardsServiceProvider.boardList);
this.boardsServiceProvider.ready.then(() => this.update());
}

private update(boardList: BoardList): void {
private update(
boardList: BoardList = this.boardsServiceProvider.boardList
): void {
const { selectedBoard, selectedPort } = boardList.boardsConfig;
this.statusBar.setElement('arduino-selected-board', {
alignment: StatusBarAlignment.RIGHT,
Expand Down