From 31fb3dd5be2b3982c844a1de0722237a6180a4f2 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Thu, 22 Sep 2022 04:17:24 -0700 Subject: [PATCH] Stop counting disabled and gatekeeped plugins as loaded Summary: Without this change gatekeeped and disabled plugins are also counted as loaded, which results in plugin duplication in the UI Reviewed By: lblasa Differential Revision: D39695335 fbshipit-source-id: 759e2e0eaead1bee0f7d61e4ba3d1b8e4b6c0976 --- .../src/dispatcher/pluginManager.tsx | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/desktop/flipper-ui-core/src/dispatcher/pluginManager.tsx b/desktop/flipper-ui-core/src/dispatcher/pluginManager.tsx index bc9ed557b..b8b79a7b3 100644 --- a/desktop/flipper-ui-core/src/dispatcher/pluginManager.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/pluginManager.tsx @@ -299,7 +299,18 @@ function updateClientPlugin( clientsWithEnabledPlugin.forEach((client) => { startPlugin(client, plugin, true); }); - store.dispatch(pluginLoaded(plugin)); + if ( + !store + .getState() + .plugins.disabledPlugins.find( + (disabledPlugin) => disabledPlugin.id === plugin.id, + ) && + !store + .getState() + .plugins.gatekeepedPlugins.find((gkPlugin) => gkPlugin.id === plugin.id) + ) { + store.dispatch(pluginLoaded(plugin)); + } } function updateDevicePlugin( @@ -317,10 +328,21 @@ function updateDevicePlugin( devicesWithEnabledPlugin.forEach((d) => { d.unloadDevicePlugin(plugin.id); }); - store.dispatch(pluginLoaded(plugin)); devicesWithEnabledPlugin.forEach((d) => { d.loadDevicePlugin(plugin); }); + if ( + !store + .getState() + .plugins.disabledPlugins.find( + (disabledPlugin) => disabledPlugin.id === plugin.id, + ) && + !store + .getState() + .plugins.gatekeepedPlugins.find((gkPlugin) => gkPlugin.id === plugin.id) + ) { + store.dispatch(pluginLoaded(plugin)); + } } function startPlugin(