mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-06-07 04:36:33 +00:00
do not await
for attached boards.
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
502e9042ad
commit
ec50ea673c
@ -105,7 +105,7 @@ export class BoardsConfig extends React.Component<BoardsConfig.Props, BoardsConf
|
|||||||
this.queryPorts(Promise.resolve({ boards })).then(({ knownPorts }) => {
|
this.queryPorts(Promise.resolve({ boards })).then(({ knownPorts }) => {
|
||||||
let { selectedPort } = this.state;
|
let { selectedPort } = this.state;
|
||||||
const removedPorts = detachedBoards.filter(AttachedSerialBoard.is).map(({ port }) => port);
|
const removedPorts = detachedBoards.filter(AttachedSerialBoard.is).map(({ port }) => port);
|
||||||
if (!!selectedPort && removedPorts.indexOf(selectedPort) === -1) {
|
if (!!selectedPort && removedPorts.indexOf(selectedPort) !== -1) {
|
||||||
selectedPort = undefined;
|
selectedPort = undefined;
|
||||||
}
|
}
|
||||||
this.setState({ knownPorts, selectedPort }, () => this.fireConfigChanged());
|
this.setState({ knownPorts, selectedPort }, () => this.fireConfigChanged());
|
||||||
|
@ -34,7 +34,7 @@ export class BoardsServiceClientImpl implements BoardsServiceClient {
|
|||||||
const { selectedPort, selectedBoard } = this.boardsConfig;
|
const { selectedPort, selectedBoard } = this.boardsConfig;
|
||||||
this.onAttachedBoardsChangedEmitter.fire(event);
|
this.onAttachedBoardsChangedEmitter.fire(event);
|
||||||
// Dynamically unset the port if the selected board was an attached one and we detached it.
|
// 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 = {
|
this.boardsConfig = {
|
||||||
selectedBoard,
|
selectedBoard,
|
||||||
selectedPort: undefined
|
selectedPort: undefined
|
||||||
|
@ -6,7 +6,6 @@ import { PlatformSearchReq, PlatformSearchResp, PlatformInstallReq, PlatformInst
|
|||||||
import { CoreClientProvider } from './core-client-provider';
|
import { CoreClientProvider } from './core-client-provider';
|
||||||
import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb';
|
import { BoardListReq, BoardListResp } from './cli-protocol/commands/board_pb';
|
||||||
import { ToolOutputServiceServer } from '../common/protocol/tool-output-service';
|
import { ToolOutputServiceServer } from '../common/protocol/tool-output-service';
|
||||||
import { Deferred } from '@theia/core/lib/common/promise-util';
|
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class BoardsServiceImpl implements BoardsService {
|
export class BoardsServiceImpl implements BoardsService {
|
||||||
@ -23,7 +22,6 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
|
|
||||||
protected selectedBoard: Board | undefined;
|
protected selectedBoard: Board | undefined;
|
||||||
protected discoveryInitialized = false;
|
protected discoveryInitialized = false;
|
||||||
protected discoveryReady = new Deferred<void>();
|
|
||||||
protected discoveryTimer: NodeJS.Timeout | undefined;
|
protected discoveryTimer: NodeJS.Timeout | undefined;
|
||||||
/**
|
/**
|
||||||
* Poor man's serial discovery:
|
* Poor man's serial discovery:
|
||||||
@ -41,7 +39,6 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
this.doGetAttachedBoards().then(({ boards }) => {
|
this.doGetAttachedBoards().then(({ boards }) => {
|
||||||
const update = (oldState: Board[], newState: Board[], message: string) => {
|
const update = (oldState: Board[], newState: Board[], message: string) => {
|
||||||
this._attachedBoards = { boards: newState };
|
this._attachedBoards = { boards: newState };
|
||||||
this.discoveryReady.resolve();
|
|
||||||
this.discoveryLogger.info(`${message} - Discovered boards: ${JSON.stringify(newState)}`);
|
this.discoveryLogger.info(`${message} - Discovered boards: ${JSON.stringify(newState)}`);
|
||||||
if (this.client) {
|
if (this.client) {
|
||||||
this.client.notifyAttachedBoardsChanged({
|
this.client.notifyAttachedBoardsChanged({
|
||||||
@ -91,7 +88,6 @@ export class BoardsServiceImpl implements BoardsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getAttachedBoards(): Promise<{ boards: Board[] }> {
|
async getAttachedBoards(): Promise<{ boards: Board[] }> {
|
||||||
await this.discoveryReady.promise;
|
|
||||||
return this._attachedBoards;
|
return this._attachedBoards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user