From cedb9617c4c8b12f58884442105aca7748d58603 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Mon, 27 Jan 2020 04:02:24 -0800 Subject: [PATCH] Fixed issue where the location bar wouldn't be updated if there are multiple connected clients Summary: The location bar doesn't update if there are multiple connected client, if the client we are interested wasn't the first one. The cause of that is that the location bar picked the state of the *first* navigation plugin found, rather than the navigation plugin connected to the selected device and client Reviewed By: jknoxville Differential Revision: D19554293 fbshipit-source-id: 46f2a66aa6ba07b510f1f615943eeb6ef8d52622 --- src/chrome/LocationsButton.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/chrome/LocationsButton.tsx b/src/chrome/LocationsButton.tsx index e2e45d467..f5c4c9c46 100644 --- a/src/chrome/LocationsButton.tsx +++ b/src/chrome/LocationsButton.tsx @@ -19,6 +19,7 @@ import {PersistedState as NavPluginState} from '../plugins/navigation/types'; import BaseDevice from '../devices/BaseDevice'; import {State as PluginState} from 'src/reducers/pluginStates'; import {platform} from 'os'; +import {getPluginKey} from '../utils/pluginUtils'; type State = { bookmarks: Array; @@ -153,10 +154,12 @@ class LocationsButton extends Component { } } -const mapStateFromPluginStatesToProps = (pluginStates: PluginState) => { - const pluginKey = Object.keys(pluginStates).find(key => - /#Navigation$/.test(key), - ); +const mapStateFromPluginStatesToProps = ( + pluginStates: PluginState, + selectedDevice: BaseDevice | null, + selectedApp: string | null, +) => { + const pluginKey = getPluginKey(selectedApp, selectedDevice, 'Navigation'); let currentURI: string | undefined; if (pluginKey) { const navPluginState = pluginStates[pluginKey] as @@ -170,8 +173,12 @@ const mapStateFromPluginStatesToProps = (pluginStates: PluginState) => { }; export default connect( - ({connections: {selectedDevice}, pluginStates}) => ({ + ({connections: {selectedDevice, selectedApp}, pluginStates}) => ({ selectedDevice, - ...mapStateFromPluginStatesToProps(pluginStates), + ...mapStateFromPluginStatesToProps( + pluginStates, + selectedDevice, + selectedApp, + ), }), )(LocationsButton);