diff --git a/desktop/app/src/dispatcher/pluginManager.tsx b/desktop/app/src/dispatcher/pluginManager.tsx index cd84884b9..a80516752 100644 --- a/desktop/app/src/dispatcher/pluginManager.tsx +++ b/desktop/app/src/dispatcher/pluginManager.tsx @@ -215,12 +215,12 @@ function starClientPlugin( ); store.dispatch(clearMessageQueue(pluginKey)); }); - store.dispatch(pluginUnstarred(plugin, selectedApp)); + store.dispatch(pluginUnstarred(plugin.id, selectedApp)); } else { clients.forEach((client) => { startPlugin(client, plugin); }); - store.dispatch(pluginStarred(plugin, selectedApp)); + store.dispatch(pluginStarred(plugin.id, selectedApp)); } } @@ -233,12 +233,12 @@ function starDevicePlugin(store: Store, plugin: DevicePluginDefinition) { devicesWithPlugin.forEach((d) => { d.unloadDevicePlugin(plugin.id); }); - store.dispatch(devicePluginUnstarred(plugin)); + store.dispatch(devicePluginUnstarred(plugin.id)); } else { devicesWithPlugin.forEach((d) => { d.loadDevicePlugin(plugin); }); - store.dispatch(devicePluginStarred(plugin)); + store.dispatch(devicePluginStarred(plugin.id)); } } @@ -251,7 +251,7 @@ function updateClientPlugin( if (enable) { const selectedApp = getSelectedAppId(store); if (selectedApp) { - store.dispatch(pluginStarred(plugin, selectedApp)); + store.dispatch(pluginStarred(plugin.id, selectedApp)); } } const clientsWithEnabledPlugin = clients.filter((c) => { @@ -283,7 +283,7 @@ function updateDevicePlugin( enable: boolean, ) { if (enable) { - store.dispatch(devicePluginStarred(plugin)); + store.dispatch(devicePluginStarred(plugin.id)); } const connections = store.getState().connections; const devicesWithEnabledPlugin = connections.devices.filter((d) => diff --git a/desktop/app/src/reducers/connections.tsx b/desktop/app/src/reducers/connections.tsx index 3af07db14..dc1b72f88 100644 --- a/desktop/app/src/reducers/connections.tsx +++ b/desktop/app/src/reducers/connections.tsx @@ -20,7 +20,6 @@ import type {Actions} from '.'; import {WelcomeScreenStaticView} from '../sandy-chrome/WelcomeScreen'; import {getPluginKey, isDevicePluginDefinition} from '../utils/pluginUtils'; import {deconstructClientId} from '../utils/clientUtils'; -import type {PluginDefinition} from '../plugin'; import type {RegisterPluginAction} from './plugins'; import MetroDevice from '../devices/MetroDevice'; import {Logger} from 'flipper-plugin'; @@ -112,27 +111,27 @@ export type Action = | { type: 'PLUGIN_STARRED'; payload: { - plugin: PluginDefinition; + pluginId: string; selectedApp: string; }; } | { type: 'DEVICE_PLUGIN_STARRED'; payload: { - plugin: PluginDefinition; + pluginId: string; }; } | { type: 'PLUGIN_UNSTARRED'; payload: { - plugin: PluginDefinition; + pluginId: string; selectedApp: string; }; } | { type: 'DEVICE_PLUGIN_UNSTARRED'; payload: { - plugin: PluginDefinition; + pluginId: string; }; } | { @@ -386,43 +385,41 @@ export default (state: State = INITAL_STATE, action: Actions): State => { return state; } case 'PLUGIN_STARRED': { - const {plugin, selectedApp} = action.payload; - const selectedPlugin = plugin.id; + const {pluginId, selectedApp} = action.payload; return produce(state, (draft) => { if (!draft.userStarredPlugins[selectedApp]) { draft.userStarredPlugins[selectedApp] = []; } const plugins = draft.userStarredPlugins[selectedApp]; - const idx = plugins.indexOf(selectedPlugin); + const idx = plugins.indexOf(pluginId); if (idx === -1) { - plugins.push(selectedPlugin); + plugins.push(pluginId); } }); } case 'DEVICE_PLUGIN_STARRED': { - const {plugin} = action.payload; + const {pluginId} = action.payload; return produce(state, (draft) => { - draft.userStarredDevicePlugins.add(plugin.id); + draft.userStarredDevicePlugins.add(pluginId); }); } case 'PLUGIN_UNSTARRED': { - const {plugin, selectedApp} = action.payload; - const selectedPlugin = plugin.id; + const {pluginId, selectedApp} = action.payload; return produce(state, (draft) => { if (!draft.userStarredPlugins[selectedApp]) { draft.userStarredPlugins[selectedApp] = []; } const plugins = draft.userStarredPlugins[selectedApp]; - const idx = plugins.indexOf(selectedPlugin); + const idx = plugins.indexOf(pluginId); if (idx !== -1) { plugins.splice(idx, 1); } }); } case 'DEVICE_PLUGIN_UNSTARRED': { - const {plugin} = action.payload; + const {pluginId} = action.payload; return produce(state, (draft) => { - draft.userStarredDevicePlugins.delete(plugin.id); + draft.userStarredDevicePlugins.delete(pluginId); }); } default: @@ -470,38 +467,32 @@ export const selectClient = (clientId: string | null): Action => ({ payload: clientId, }); -export const pluginStarred = ( - plugin: PluginDefinition, - appId: string, -): Action => ({ +export const pluginStarred = (pluginId: string, appId: string): Action => ({ type: 'PLUGIN_STARRED', payload: { - plugin, + pluginId, selectedApp: appId, }, }); -export const devicePluginStarred = (plugin: PluginDefinition): Action => ({ +export const devicePluginStarred = (pluginId: string): Action => ({ type: 'DEVICE_PLUGIN_STARRED', payload: { - plugin, + pluginId, }, }); -export const devicePluginUnstarred = (plugin: PluginDefinition): Action => ({ +export const devicePluginUnstarred = (pluginId: string): Action => ({ type: 'DEVICE_PLUGIN_UNSTARRED', payload: { - plugin, + pluginId, }, }); -export const pluginUnstarred = ( - plugin: PluginDefinition, - appId: string, -): Action => ({ +export const pluginUnstarred = (pluginId: string, appId: string): Action => ({ type: 'PLUGIN_UNSTARRED', payload: { - plugin, + pluginId, selectedApp: appId, }, });