From f4822143bda00de5faf5f736e51e3422306da120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Thu, 16 Aug 2018 07:59:10 -0700 Subject: [PATCH] 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 --- src/reducers/connections.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/reducers/connections.js b/src/reducers/connections.js index c8a49ee1c..779b71327 100644 --- a/src/reducers/connections.js +++ b/src/reducers/connections.js @@ -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; + + // select the default plugin + let selection = { + selectedApp: null, + selectedPlugin: DEFAULT_PLUGIN, + }; if (!selectedDevice) { selectedDevice = payload; - selection = { - selectedApp: null, - selectedPlugin: DEFAULT_PLUGIN, - }; + 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 {