Skip to content

Commit 7973130

Browse files
committed
Reestablish monitor connection after reloading the window, reconnect after selecting another board
Signed-off-by: jbicker <[email protected]>
1 parent 2046c0b commit 7973130

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

arduino-ide-extension/src/browser/monitor/monitor-widget.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,22 +195,29 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
195195
super.onAfterAttach(msg);
196196
this.clear();
197197
this.connect();
198-
this.toDisposeOnDetach.push(this.boardsServiceClient.onBoardsChanged(async states => {
199-
const currentConnectionConfig = this.connection.connectionConfig;
200-
const connectedBoard = states.newState.boards
201-
.filter(AttachedSerialBoard.is)
202-
.find(board => {
203-
const potentiallyConnected = currentConnectionConfig && currentConnectionConfig.board;
204-
if (AttachedSerialBoard.is(potentiallyConnected)) {
205-
return Board.equals(board, potentiallyConnected) && board.port === potentiallyConnected.port;
206-
}
207-
return false;
208-
});
209-
if (connectedBoard && currentConnectionConfig) {
210-
this.continuePreviousConnection = true;
211-
this.connection.connect(currentConnectionConfig);
212-
}
213-
}));
198+
this.toDisposeOnDetach.push(
199+
this.boardsServiceClient.onBoardsChanged(async states => {
200+
const currentConnectionConfig = this.connection.connectionConfig;
201+
const connectedBoard = states.newState.boards
202+
.filter(AttachedSerialBoard.is)
203+
.find(board => {
204+
const potentiallyConnected = currentConnectionConfig && currentConnectionConfig.board;
205+
if (AttachedSerialBoard.is(potentiallyConnected)) {
206+
return Board.equals(board, potentiallyConnected) && board.port === potentiallyConnected.port;
207+
}
208+
return false;
209+
});
210+
if (connectedBoard && currentConnectionConfig) {
211+
this.continuePreviousConnection = true;
212+
this.connection.connect(currentConnectionConfig);
213+
}
214+
})
215+
);
216+
this.toDisposeOnDetach.push(
217+
this.boardsServiceClient.onBoardsConfigChanged(async boardConfig => {
218+
this.connect();
219+
})
220+
)
214221

215222
this.toDisposeOnDetach.push(this.connection.onConnectionChanged(() => {
216223
if (!this.continuePreviousConnection) {
@@ -255,7 +262,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
255262
const attachedBoards = await this.boardsService.getAttachedBoards();
256263
const connectedBoard = attachedBoards.boards.filter(AttachedSerialBoard.is).find(board => BoardsConfig.Config.sameAs(boardsConfig, board));
257264
if (!connectedBoard) {
258-
this.messageService.warn(`The selected '${name}' board is not connected on ${selectedPort}.`);
259265
return;
260266
}
261267

0 commit comments

Comments
 (0)