Fix bug preventing manual snes reconnect. Update WebUI to automatically connect if only one SNES device is detected.

This commit is contained in:
Chris
2020-06-06 19:58:10 -04:00
parent fbd00136e7
commit 7d42137782
4 changed files with 28 additions and 40 deletions

View File

@@ -41,20 +41,24 @@ class MonitorControls extends Component {
if (this.props.webSocket) {
// Poll for available devices
this.pollSnesDevices();
setTimeout(() => {
if (this.props.availableDevices.length === 1) {
this.setState({ deviceId: this.props.availableDevices[0] }, () => {
if (!this.props.snesConnected) {
this.connectToSnes();
}
});
}
}, 500);
}
}, 500);
}
componentDidUpdate(prevProps) {
if (
prevProps.availableDevices.length !== this.props.availableDevices.length &&
this.props.availableDevices.length === 1
) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ deviceId: this.props.availableDevices[0] }, () => {
if (!this.props.snesConnected) {
this.connectToSnes();
}
});
}
}
increaseTextSize = () => {
if (this.props.fontSize >= 25) return;
this.props.updateFontSize(this.props.fontSize + 1);