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:
committed by
Facebook Github Bot
parent
286f0d7acf
commit
5288c4ac93
@@ -38,7 +38,7 @@ export default (store: Store, logger: Logger) => {
|
|||||||
store.dispatch({
|
store.dispatch({
|
||||||
type: 'CLEAR_PLUGIN_STATE',
|
type: 'CLEAR_PLUGIN_STATE',
|
||||||
payload: {
|
payload: {
|
||||||
id,
|
clientId: id,
|
||||||
devicePlugins: new Set([
|
devicePlugins: new Set([
|
||||||
...store.getState().plugins.devicePlugins.keys(),
|
...store.getState().plugins.devicePlugins.keys(),
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ test('CLEAR_PLUGIN_STATE removes plugin state', () => {
|
|||||||
|
|
||||||
const action: Action = {
|
const action: Action = {
|
||||||
type: 'CLEAR_PLUGIN_STATE',
|
type: 'CLEAR_PLUGIN_STATE',
|
||||||
payload: {id: clientId, devicePlugins: new Set()},
|
payload: {clientId: clientId, devicePlugins: new Set()},
|
||||||
};
|
};
|
||||||
const result = reducer(
|
const result = reducer(
|
||||||
{[pluginKey]: {a: 1}, 'anotherPlugin#key': {b: 2}},
|
{[pluginKey]: {a: 1}, 'anotherPlugin#key': {b: 2}},
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export type Action =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'CLEAR_PLUGIN_STATE',
|
type: 'CLEAR_PLUGIN_STATE',
|
||||||
payload: {id: string, devicePlugins: Set<string>},
|
payload: {clientId: string, devicePlugins: Set<string>},
|
||||||
};
|
};
|
||||||
|
|
||||||
const INITIAL_STATE: State = {};
|
const INITIAL_STATE: State = {};
|
||||||
@@ -51,7 +51,10 @@ export default function reducer(
|
|||||||
// was removed. pluginKeys are in the form of ${clientID}#${pluginID}.
|
// was removed. pluginKeys are in the form of ${clientID}#${pluginID}.
|
||||||
const clientId = pluginKey.slice(0, pluginKey.lastIndexOf('#'));
|
const clientId = pluginKey.slice(0, pluginKey.lastIndexOf('#'));
|
||||||
const pluginId = pluginKey.split('#').pop();
|
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];
|
newState[pluginKey] = state[pluginKey];
|
||||||
}
|
}
|
||||||
return newState;
|
return newState;
|
||||||
|
|||||||
Reference in New Issue
Block a user