Continue monitoring with last connection if respective board is reconnected

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker 2019-08-20 13:30:40 +02:00
parent 3eebd580d8
commit 2046c0bdee

View File

@ -131,6 +131,8 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
protected widgetHeight: number;
protected continuePreviousConnection: boolean;
constructor(
@inject(MonitorServiceClientImpl) protected readonly serviceClient: MonitorServiceClientImpl,
@inject(MonitorConnection) protected readonly connection: MonitorConnection,
@ -204,13 +206,18 @@ export class MonitorWidget extends ReactWidget implements StatefulWidget {
}
return false;
});
if (!connectedBoard) {
this.close();
if (connectedBoard && currentConnectionConfig) {
this.continuePreviousConnection = true;
this.connection.connect(currentConnectionConfig);
}
}));
this.toDisposeOnDetach.push(this.connection.onConnectionChanged(() => {
if (!this.continuePreviousConnection) {
this.clear();
} else {
this.continuePreviousConnection = false;
}
}));
}