fine tuned selectedPort update

based on the detached boards.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta 2019-07-31 14:43:19 +02:00 committed by jbicker
parent 66f429c478
commit 502e9042ad

View File

@ -30,11 +30,11 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
notifyAttachedBoardsChanged(event: AttachedBoardsChangeEvent): void {
this.logger.info('Attached boards changed: ', JSON.stringify(event));
const { boards } = event.newState;
const detachedBoards = AttachedBoardsChangeEvent.diff(event).detached.filter(AttachedSerialBoard.is).map(({ port }) => port);
const { selectedPort, selectedBoard } = this.boardsConfig;
this.onAttachedBoardsChangedEmitter.fire(event);
// Dynamically unset the port if there is not corresponding attached boards for it.
if (!!selectedPort && boards.filter(AttachedSerialBoard.is).map(({ port }) => port).indexOf(selectedPort) === -1) {
// Dynamically unset the port if the selected board was an attached one and we detached it.
if (!!selectedPort && detachedBoards.indexOf(selectedPort) === -1) {
this.boardsConfig = {
selectedBoard,
selectedPort: undefined