No disconnect/reconnect when DNDing the widget.

- Updated to next Theia,
 - Added elecron launch config,
 - Yet another syling for the input + selects,
 - Close monitor connection on widget close not detach.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2019-12-06 10:09:30 +01:00
parent 6154d1e8d5
commit 2f33038695
7 changed files with 925 additions and 501 deletions

View File

@@ -1,6 +1,7 @@
import * as PQueue from 'p-queue';
import { injectable, inject, postConstruct, named } from 'inversify';
import { ILogger } from '@theia/core/lib/common/logger';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { BoardsService, AttachedSerialBoard, BoardPackage, Board, AttachedNetworkBoard, BoardsServiceClient, Port } from '../common/protocol/boards-service';
import {
PlatformSearchReq,
@@ -43,6 +44,7 @@ export class BoardsServiceImpl implements BoardsService {
*/
protected attachedBoards: { boards: Board[] } = { boards: [] };
protected availablePorts: { ports: Port[] } = { ports: [] };
protected started = new Deferred<void>();
protected client: BoardsServiceClient | undefined;
protected readonly queue = new PQueue({ autoStart: true, concurrency: 1 });
@@ -74,6 +76,7 @@ export class BoardsServiceImpl implements BoardsService {
if (!this.discoveryInitialized) {
update([], sortedBoards, [], sortedPorts, 'Initialized attached boards and available ports.');
this.discoveryInitialized = true;
this.started.resolve();
} else {
Promise.all([
this.getAttachedBoards(),
@@ -120,10 +123,12 @@ export class BoardsServiceImpl implements BoardsService {
}
async getAttachedBoards(): Promise<{ boards: Board[] }> {
await this.started.promise;
return this.attachedBoards;
}
async getAvailablePorts(): Promise<{ ports: Port[] }> {
await this.started.promise;
return this.availablePorts;
}

View File

@@ -71,7 +71,7 @@ export class MonitorServiceImpl implements MonitorService {
duplex.on('error', ((error: Error) => {
const monitorError = ErrorWithCode.toMonitorError(error, config);
this.disconnect().then(() => {
this.disconnect(monitorError).then(() => {
if (this.client) {
this.client.notifyError(monitorError);
}
@@ -112,7 +112,10 @@ export class MonitorServiceImpl implements MonitorService {
});
}
async disconnect(): Promise<Status> {
async disconnect(reason?: MonitorError): Promise<Status> {
if (!this.connection && reason && reason.code === MonitorError.ErrorCodes.CLIENT_CANCEL) {
return Status.OK;
}
this.logger.info(`>>> Disposing monitor connection...`);
if (!this.connection) {
this.logger.warn(`<<< Not connected. Nothing to dispose.`);