|
@@ -45,6 +45,7 @@ class App extends Component {
|
|
|
readyToFlash: false,
|
|
|
isFlashing: false,
|
|
|
firstRun: true,
|
|
|
+ isScanningForPorts: false,
|
|
|
percent: 100,
|
|
|
status: 'Finding ports and manifests...'
|
|
|
};
|
|
@@ -72,8 +73,6 @@ class App extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
prepareEventHandlers() {
|
|
|
ipcRenderer.on('portsFound', (event, ports) => this.portsFound(ports));
|
|
|
ipcRenderer.on('noPortError', (event, error) => {
|
|
@@ -108,12 +107,20 @@ class App extends Component {
|
|
|
}
|
|
|
|
|
|
componentWillMount() {
|
|
|
+ this.scanForPortsInterval = setInterval(() => {
|
|
|
+ if (!this.state.isFlashing && !this.state.isScanningForPorts) {
|
|
|
+ this.setState({isScanningForPorts: true});
|
|
|
+ this.scanForPorts();
|
|
|
+ }
|
|
|
+ }, CONSTANTS.pollTime);
|
|
|
this.prepareEventHandlers();
|
|
|
-
|
|
|
- this.scanForPorts();
|
|
|
this.fetchManifests();
|
|
|
}
|
|
|
|
|
|
+ componentWillUnmount() {
|
|
|
+ clearInterval(this.scanForPortsInterval);
|
|
|
+ }
|
|
|
+
|
|
|
scanForPorts() {
|
|
|
ipcRenderer.send('scanForPorts');
|
|
|
}
|
|
@@ -125,14 +132,13 @@ class App extends Component {
|
|
|
const isFirstSerialPortAdded = this.state.ports.length === 0 && portValues.length > 0;
|
|
|
const isLastSerialPort = portValues.length === 1;
|
|
|
|
|
|
- const newState = { ports: portValues };
|
|
|
+ const newState = { ports: portValues, isScanningForPorts: false };
|
|
|
|
|
|
if (isFirstSerialPortAdded || isLastSerialPort) {
|
|
|
Object.assign(newState, { selectedPort: portValues[0].value });
|
|
|
}
|
|
|
|
|
|
this.setState(newState);
|
|
|
- if (!this.state.isFlashing) this.scanForPorts()
|
|
|
this.prepareUI();
|
|
|
}
|
|
|
|