From 5288c4ac93d5fee441d74d4337d38ce30173f7fa Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 18 Jul 2019 05:23:02 -0700 Subject: [PATCH] Rename id in CLEAR_PLUGIN_STATE event Summary: There's been a bug here where the id was treated as a pluginId. Renaming to make it clear. Reviewed By: passy Differential Revision: D16338884 fbshipit-source-id: 42c6c92653811d88cd37ebf4834346b1f0bb2c2a --- src/dispatcher/server.js | 2 +- src/reducers/__tests__/pluginStates.node.js | 2 +- src/reducers/pluginStates.js | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dispatcher/server.js b/src/dispatcher/server.js index 3057bac8f..f477dfb12 100644 --- a/src/dispatcher/server.js +++ b/src/dispatcher/server.js @@ -38,7 +38,7 @@ export default (store: Store, logger: Logger) => { store.dispatch({ type: 'CLEAR_PLUGIN_STATE', payload: { - id, + clientId: id, devicePlugins: new Set([ ...store.getState().plugins.devicePlugins.keys(), ]), diff --git a/src/reducers/__tests__/pluginStates.node.js b/src/reducers/__tests__/pluginStates.node.js index 57c5a7bd2..ae8c17844 100644 --- a/src/reducers/__tests__/pluginStates.node.js +++ b/src/reducers/__tests__/pluginStates.node.js @@ -22,7 +22,7 @@ test('CLEAR_PLUGIN_STATE removes plugin state', () => { const action: Action = { type: 'CLEAR_PLUGIN_STATE', - payload: {id: clientId, devicePlugins: new Set()}, + payload: {clientId: clientId, devicePlugins: new Set()}, }; const result = reducer( {[pluginKey]: {a: 1}, 'anotherPlugin#key': {b: 2}}, diff --git a/src/reducers/pluginStates.js b/src/reducers/pluginStates.js index 6f899971a..361652c70 100644 --- a/src/reducers/pluginStates.js +++ b/src/reducers/pluginStates.js @@ -23,7 +23,7 @@ export type Action = } | { type: 'CLEAR_PLUGIN_STATE', - payload: {id: string, devicePlugins: Set}, + payload: {clientId: string, devicePlugins: Set}, }; const INITIAL_STATE: State = {}; @@ -51,7 +51,10 @@ export default function reducer( // was removed. pluginKeys are in the form of ${clientID}#${pluginID}. const clientId = pluginKey.slice(0, pluginKey.lastIndexOf('#')); const pluginId = pluginKey.split('#').pop(); - if (clientId !== payload.id || payload.devicePlugins.has(pluginId)) { + if ( + clientId !== payload.clientId || + payload.devicePlugins.has(pluginId) + ) { newState[pluginKey] = state[pluginKey]; } return newState;