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
This commit is contained in:
John Knox
2019-07-18 05:23:02 -07:00
committed by Facebook Github Bot
parent 286f0d7acf
commit 5288c4ac93
3 changed files with 7 additions and 4 deletions

View File

@@ -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(),
]),

View File

@@ -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}},

View File

@@ -23,7 +23,7 @@ export type Action =
}
| {
type: 'CLEAR_PLUGIN_STATE',
payload: {id: string, devicePlugins: Set<string>},
payload: {clientId: string, devicePlugins: Set<string>},
};
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;