Reestablish monitor connection after reloading the window, reconnect after selecting another board

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker 2019-08-20 14:32:42 +02:00
parent 2046c0bdee
commit 79731304c1

View File

@ -195,7 +195,8 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
super.onAfterAttach(msg); super.onAfterAttach(msg);
this.clear(); this.clear();
this.connect(); this.connect();
this.toDisposeOnDetach.push(this.boardsServiceClient.onBoardsChanged(async states => { this.toDisposeOnDetach.push(
this.boardsServiceClient.onBoardsChanged(async states => {
const currentConnectionConfig = this.connection.connectionConfig; const currentConnectionConfig = this.connection.connectionConfig;
const connectedBoard = states.newState.boards const connectedBoard = states.newState.boards
.filter(AttachedSerialBoard.is) .filter(AttachedSerialBoard.is)
@ -210,7 +211,13 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
this.continuePreviousConnection = true; this.continuePreviousConnection = true;
this.connection.connect(currentConnectionConfig); this.connection.connect(currentConnectionConfig);
} }
})); })
);
this.toDisposeOnDetach.push(
this.boardsServiceClient.onBoardsConfigChanged(async boardConfig => {
this.connect();
})
)
this.toDisposeOnDetach.push(this.connection.onConnectionChanged(() => { this.toDisposeOnDetach.push(this.connection.onConnectionChanged(() => {
if (!this.continuePreviousConnection) { if (!this.continuePreviousConnection) {
@ -255,7 +262,6 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
const attachedBoards = await this.boardsService.getAttachedBoards(); const attachedBoards = await this.boardsService.getAttachedBoards();
const connectedBoard = attachedBoards.boards.filter(AttachedSerialBoard.is).find(board => BoardsConfig.Config.sameAs(boardsConfig, board)); const connectedBoard = attachedBoards.boards.filter(AttachedSerialBoard.is).find(board => BoardsConfig.Config.sameAs(boardsConfig, board));
if (!connectedBoard) { if (!connectedBoard) {
this.messageService.warn(`The selected '${name}' board is not connected on ${selectedPort}.`);
return; return;
} }