Don't throw if selectedPlugin doesn't exist
Summary: When a plugin was selected the last time Flipper was running, but is not available anymore, Flipper was still trying to load the plugin and failed. Now, if the selected plugin is not available, we just don't render anything. Reviewed By: jknoxville Differential Revision: D14854930 fbshipit-source-id: 9ddec47becce7bffcf93b3f4a092a8fcf2022f4f
This commit is contained in:
committed by
Facebook Github Bot
parent
f21c9f1c61
commit
c4a8e73543
@@ -39,13 +39,6 @@ const SidebarContainer = styled(FlexRow)({
|
||||
overflow: 'scroll',
|
||||
});
|
||||
|
||||
/*
|
||||
pluginState: pluginStates[pluginKey],
|
||||
activePlugin,
|
||||
target,
|
||||
deepLinkPayload,
|
||||
pluginKey,
|
||||
*/
|
||||
type OwnProps = {|
|
||||
logger: Logger,
|
||||
|};
|
||||
@@ -55,7 +48,7 @@ type Props = {|
|
||||
pluginState: Object,
|
||||
activePlugin: ?Class<FlipperPlugin<> | FlipperDevicePlugin<>>,
|
||||
target: Client | BaseDevice | null,
|
||||
pluginKey: string,
|
||||
pluginKey: ?string,
|
||||
deepLinkPayload: ?string,
|
||||
|
||||
selectPlugin: (payload: {|
|
||||
@@ -95,7 +88,8 @@ class PluginContainer extends PureComponent<Props> {
|
||||
target,
|
||||
isArchivedDevice,
|
||||
} = this.props;
|
||||
if (!activePlugin || !target) {
|
||||
if (!activePlugin || !target || !pluginKey) {
|
||||
console.warn(`No selected plugin. Rendering empty!`);
|
||||
return null;
|
||||
}
|
||||
const props: PluginProps<Object> = {
|
||||
@@ -158,7 +152,7 @@ export default connect<Props, OwnProps, _, _, _, _>(
|
||||
pluginStates,
|
||||
plugins: {devicePlugins, clientPlugins},
|
||||
}) => {
|
||||
let pluginKey = 'unknown';
|
||||
let pluginKey = null;
|
||||
let target = null;
|
||||
let activePlugin: ?Class<FlipperPlugin<> | FlipperDevicePlugin<>> = null;
|
||||
|
||||
@@ -174,12 +168,9 @@ export default connect<Props, OwnProps, _, _, _, _>(
|
||||
} else {
|
||||
target = clients.find((client: Client) => client.id === selectedApp);
|
||||
activePlugin = clientPlugins.get(selectedPlugin);
|
||||
if (!activePlugin || !target) {
|
||||
throw new Error(
|
||||
`Plugin "${selectedPlugin || ''}" could not be found.`,
|
||||
);
|
||||
if (activePlugin && target) {
|
||||
pluginKey = getPluginKey(target.id, activePlugin.id);
|
||||
}
|
||||
pluginKey = getPluginKey(target.id, activePlugin.id);
|
||||
}
|
||||
}
|
||||
const isArchivedDevice = !selectedDevice
|
||||
|
||||
Reference in New Issue
Block a user