diff --git a/src/containers/scanning-step.jsx b/src/containers/scanning-step.jsx index bdab6c8a6ebbc0dacbc6616acb753d967093a7fb..600eb8da8e0c05f3571446997d2efecab813923b 100644 --- a/src/containers/scanning-step.jsx +++ b/src/containers/scanning-step.jsx @@ -9,6 +9,7 @@ class ScanningStep extends React.Component { super(props); bindAll(this, [ 'handlePeripheralListUpdate', + 'handlePeripheralScanTimeout', 'handleRefresh' ]); this.state = { @@ -20,11 +21,18 @@ class ScanningStep extends React.Component { this.props.vm.startDeviceScan(this.props.extensionId); this.props.vm.on( 'PERIPHERAL_LIST_UPDATE', this.handlePeripheralListUpdate); + this.props.vm.on( + 'PERIPHERAL_SCAN_TIMEOUT', this.handlePeripheralScanTimeout); } componentWillUnmount () { // @todo: stop the device scan here this.props.vm.removeListener( 'PERIPHERAL_LIST_UPDATE', this.handlePeripheralListUpdate); + this.props.vm.removeListener( + 'PERIPHERAL_SCAN_TIMEOUT', this.handlePeripheralScanTimeout); + } + handlePeripheralScanTimeout () { + this.setState({scanning: false}); } handlePeripheralListUpdate (newList) { // TODO: sort peripherals by signal strength? so they don't jump around