From ec50ea673ca0db922d991da6984412c57a2b91df Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Wed, 31 Jul 2019 15:24:19 +0200 Subject: [PATCH] do not `await` for attached boards. Signed-off-by: Akos Kitta --- arduino-ide-extension/src/browser/boards/boards-config.tsx | 2 +- .../src/browser/boards/boards-service-client-impl.ts | 2 +- arduino-ide-extension/src/node/boards-service-impl.ts | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/arduino-ide-extension/src/browser/boards/boards-config.tsx b/arduino-ide-extension/src/browser/boards/boards-config.tsx index 9509f46f..3e294eb0 100644 --- a/arduino-ide-extension/src/browser/boards/boards-config.tsx +++ b/arduino-ide-extension/src/browser/boards/boards-config.tsx @@ -105,7 +105,7 @@ export class BoardsConfig extends React.Component { let { selectedPort } = this.state; const removedPorts = detachedBoards.filter(AttachedSerialBoard.is).map(({ port }) => port); - if (!!selectedPort && removedPorts.indexOf(selectedPort) === -1) { + if (!!selectedPort && removedPorts.indexOf(selectedPort) !== -1) { selectedPort = undefined; } this.setState({ knownPorts, selectedPort }, () => this.fireConfigChanged()); diff --git a/arduino-ide-extension/src/browser/boards/boards-service-client-impl.ts b/arduino-ide-extension/src/browser/boards/boards-service-client-impl.ts index 0d8822f0..3ceb5d8f 100644 --- a/arduino-ide-extension/src/browser/boards/boards-service-client-impl.ts +++ b/arduino-ide-extension/src/browser/boards/boards-service-client-impl.ts @@ -34,7 +34,7 @@ export class BoardsServiceClientImpl implements BoardsServiceClient { const { selectedPort, selectedBoard } = this.boardsConfig; this.onAttachedBoardsChangedEmitter.fire(event); // Dynamically unset the port if the selected board was an attached one and we detached it. - if (!!selectedPort && detachedBoards.indexOf(selectedPort) === -1) { + if (!!selectedPort && detachedBoards.indexOf(selectedPort) !== -1) { this.boardsConfig = { selectedBoard, selectedPort: undefined diff --git a/arduino-ide-extension/src/node/boards-service-impl.ts b/arduino-ide-extension/src/node/boards-service-impl.ts index 843d0a87..8971a28c 100644 --- a/arduino-ide-extension/src/node/boards-service-impl.ts +++ b/arduino-ide-extension/src/node/boards-service-impl.ts @@ -6,7 +6,6 @@ import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInst import { CoreClientProvider } from './core-client-provider'; import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb'; import { ToolOutputServiceServer } from '../common/protocol/tool-output-service'; -import { Deferred } from '@theia/core/lib/common/promise-util'; @injectable() export class BoardsServiceImpl implements BoardsService { @@ -23,7 +22,6 @@ export class BoardsServiceImpl implements BoardsService { protected selectedBoard: Board | undefined; protected discoveryInitialized = false; - protected discoveryReady = new Deferred(); protected discoveryTimer: NodeJS.Timeout | undefined; /** * Poor man's serial discovery: @@ -41,7 +39,6 @@ export class BoardsServiceImpl implements BoardsService { this.doGetAttachedBoards().then(({ boards }) => { const update = (oldState: Board[], newState: Board[], message: string) => { this._attachedBoards = { boards: newState }; - this.discoveryReady.resolve(); this.discoveryLogger.info(`${message} - Discovered boards: ${JSON.stringify(newState)}`); if (this.client) { this.client.notifyAttachedBoardsChanged({ @@ -91,7 +88,6 @@ export class BoardsServiceImpl implements BoardsService { } async getAttachedBoards(): Promise<{ boards: Board[] }> { - await this.discoveryReady.promise; return this._attachedBoards; }