Store use selected plugin after reconnect
Summary: Deselect plugin when app disconnects, but store the information that the users had the app selected. When the app conencts again, restore the user's selection. This also stores the device seleced by the user and reselects the device if it connects. Reviewed By: xiphirx Differential Revision: D8833948 fbshipit-source-id: ad3ef54681550ae674bdd4e695d677aea5c14588
This commit is contained in:
committed by
Pascal Hartig
parent
a8138984f9
commit
1f977f4844
@@ -7,8 +7,8 @@
|
||||
|
||||
import {Component, Button} from 'sonar';
|
||||
import {connect} from 'react-redux';
|
||||
import {exec} from 'child_process';
|
||||
import {selectDevice} from '../reducers/connections.js';
|
||||
import {spawn} from 'child_process';
|
||||
import {selectDevice, preferDevice} from '../reducers/connections.js';
|
||||
import type BaseDevice from '../devices/BaseDevice.js';
|
||||
|
||||
type Props = {
|
||||
@@ -16,15 +16,21 @@ type Props = {
|
||||
androidEmulators: Array<string>,
|
||||
devices: Array<BaseDevice>,
|
||||
selectDevice: (device: BaseDevice) => void,
|
||||
preferDevice: (device: string) => void,
|
||||
};
|
||||
|
||||
class DevicesButton extends Component<Props> {
|
||||
launchEmulator = (name: string) => {
|
||||
exec(`$ANDROID_HOME/tools/emulator @${name}`, error => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
const child = spawn(
|
||||
`${process.env.ANDROID_HOME || ''}/tools/emulator`,
|
||||
[`@${name}`],
|
||||
{
|
||||
detached: true,
|
||||
stdio: 'ignore',
|
||||
},
|
||||
);
|
||||
child.on('error', console.error);
|
||||
this.props.preferDevice(name);
|
||||
};
|
||||
|
||||
render() {
|
||||
@@ -96,5 +102,5 @@ export default connect(
|
||||
androidEmulators,
|
||||
selectedDevice,
|
||||
}),
|
||||
{selectDevice},
|
||||
{selectDevice, preferDevice},
|
||||
)(DevicesButton);
|
||||
|
||||
Reference in New Issue
Block a user