plugin reselection

Summary: When relaunching Flipper/refreshing it while developing, where was a case, where the App Client connected, before the device was registered in Flipper. In this case, we didn't select the previously selected plugin

Reviewed By: jknoxville

Differential Revision: D9359779

fbshipit-source-id: 9c6f8e6bf65a46dc84c9781242b23df0ed539810
This commit is contained in:
Daniel Büchele
2018-08-16 07:59:10 -07:00
committed by Facebook Github Bot
parent cded1ceead
commit f4822143bd

View File

@@ -102,17 +102,27 @@ export default function reducer(
case 'REGISTER_DEVICE': {
const {payload} = action;
const devices = state.devices.concat(payload);
let {selectedDevice} = state;
let selection = {};
let {selectedDevice, selectedPlugin} = state;
if (!selectedDevice) {
selectedDevice = payload;
selection = {
// select the default plugin
let selection = {
selectedApp: null,
selectedPlugin: DEFAULT_PLUGIN,
};
if (!selectedDevice) {
selectedDevice = payload;
if (selectedPlugin) {
// We already had a plugin selected, but no device. This is happening
// when the Client connected before the Device.
selection = {};
}
} else if (payload.title === state.userPreferredDevice) {
selectedDevice = payload;
} else {
// We didn't select the newly connected device, so we don't want to
// change the plugin.
selection = {};
}
return {