Skip to content

Commit 7c9cd67

Browse files
author
smellai
committed
do not open when uploading Fixes #18
1 parent 5d22215 commit 7c9cd67

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/daemon.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class Daemon {
2020
this.serialMonitorMessages = new Subject();
2121
this.uploading = new BehaviorSubject({ status: this.UPLOAD_NOPE });
2222
this.uploadingDone = this.uploading.pipe(filter(upload => upload.status === this.UPLOAD_DONE));
23+
this.uploadInProgress = this.uploading.pipe(filter(upload => upload.status === this.UPLOAD_IN_PROGRESS));
2324
this.uploadingError = this.uploading.pipe(filter(upload => upload.status === this.UPLOAD_ERROR));
2425
this.devicesList = new BehaviorSubject({
2526
serial: [],

src/socket-daemon.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import semVerCompare from 'semver-compare';
3232
import { detect } from 'detect-browser';
3333

3434
import { BehaviorSubject, timer } from 'rxjs';
35-
import { takeUntil, filter } from 'rxjs/operators';
35+
import { delayWhen, filter, takeUntil, first } from 'rxjs/operators';
3636

3737
import Daemon from './daemon';
3838

@@ -278,9 +278,10 @@ export default class SocketDaemon extends Daemon {
278278
* @param {string} port the port name
279279
*/
280280
openSerialMonitor(port, baudrate) {
281-
if (this.serialMonitorOpened.getValue()) {
281+
if (this.serialMonitorOpened.getValue() || this.uploading.getValue().status === this.UPLOAD_IN_PROGRESS) {
282282
return;
283283
}
284+
284285
const serialPort = this.devicesList.getValue().serial.find(p => p.Name === port);
285286
if (!serialPort) {
286287
return this.serialMonitorOpened.error(new Error(`Can't find port ${port}`));
@@ -295,6 +296,7 @@ export default class SocketDaemon extends Daemon {
295296
this.serialMonitorOpened.error(new Error(`Failed to open serial ${port}`));
296297
}
297298
});
299+
298300
this.socket.emit('command', `open ${port} ${baudrate} timed`);
299301
}
300302

0 commit comments

Comments
 (0)