Skip to content

Commit 504e351

Browse files
silvanocerzaAlberto Iannaccone
authored and
Alberto Iannaccone
committed
Fix Tools > Port menu not refreshing
1 parent 17e6d50 commit 504e351

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Diff for: arduino-ide-extension/src/browser/boards/boards-service-provider.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
4242
protected readonly onAvailableBoardsChangedEmitter = new Emitter<
4343
AvailableBoard[]
4444
>();
45+
protected readonly onAvailablePortsChangedEmitter = new Emitter<Port[]>();
4546

4647
/**
4748
* Used for the auto-reconnecting. Sometimes, the attached board gets disconnected after uploading something to it.
@@ -67,8 +68,8 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
6768
* This event is also emitted when the board package for the currently selected board was uninstalled.
6869
*/
6970
readonly onBoardsConfigChanged = this.onBoardsConfigChangedEmitter.event;
70-
readonly onAvailableBoardsChanged =
71-
this.onAvailableBoardsChangedEmitter.event;
71+
readonly onAvailableBoardsChanged = this.onAvailableBoardsChangedEmitter.event;
72+
readonly onAvailablePortsChanged = this.onAvailablePortsChangedEmitter.event;
7273

7374
onStart(): void {
7475
this.notificationCenter.onAttachedBoardsChanged(
@@ -88,6 +89,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
8889
]).then(([attachedBoards, availablePorts]) => {
8990
this._attachedBoards = attachedBoards;
9091
this._availablePorts = availablePorts;
92+
this.onAvailablePortsChangedEmitter.fire(this._availablePorts);
9193
this.reconcileAvailableBoards().then(() => this.tryReconnect());
9294
});
9395
}
@@ -102,6 +104,7 @@ export class BoardsServiceProvider implements FrontendApplicationContribution {
102104
}
103105
this._attachedBoards = event.newState.boards;
104106
this._availablePorts = event.newState.ports;
107+
this.onAvailablePortsChangedEmitter.fire(this._availablePorts);
105108
this.reconcileAvailableBoards().then(() => this.tryReconnect());
106109
}
107110

@@ -601,8 +604,8 @@ export namespace AvailableBoard {
601604
return -1;
602605
} else if (left.port?.protocol !== "network" && right.port?.protocol === "network") {
603606
return 1;
604-
} else if (left.port?.protocol === "serial" && right.port?.protocol === "serial") {
605-
// We show all serial ports, including those that have guessed
607+
} else if (left.port?.protocol === right.port?.protocol) {
608+
// We show all ports, including those that have guessed
606609
// or unrecognized boards, so we must sort those too.
607610
if (left.state < right.state) {
608611
return -1;

Diff for: arduino-ide-extension/src/browser/contributions/board-selection.ts

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ PID: ${PID}`;
110110
this.boardsServiceProvider.onAvailableBoardsChanged(
111111
this.updateMenus.bind(this)
112112
);
113+
this.boardsServiceProvider.onAvailablePortsChanged(
114+
this.updateMenus.bind(this)
115+
);
113116
}
114117

115118
protected async updateMenus(): Promise<void> {

0 commit comments

Comments
 (0)