From d48f93edeac448e316bb2a33654b2cb0fb6b6224 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 19 Oct 2018 03:36:05 -0700 Subject: [PATCH] Add method field to persistedStateReducer Summary: When sending a message from the mobile side, you call something like: `send(method: string, params: Object)` But when receiving it in the reducer, you only get the params. Adding method so you can distinguish them. Reviewed By: passy Differential Revision: D10447890 fbshipit-source-id: f1fe925e82355866f86b322ecd3c72c604ae86af --- src/Client.js | 1 + src/plugin.js | 6 +++++- src/plugins/network/index.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Client.js b/src/Client.js index c64f510cc..e946ea31a 100644 --- a/src/Client.js +++ b/src/Client.js @@ -173,6 +173,7 @@ export default class Client extends EventEmitter { // $FlowFixMe: We checked persistedStateReducer exists const newPluginState = persistingPlugin.persistedStateReducer( persistedState, + params.method, params.params, ); this.store.dispatch( diff --git a/src/plugin.js b/src/plugin.js index 87a20c84a..2c8c9252c 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -126,7 +126,11 @@ export class FlipperPlugin extends FlipperBasePlugin< A, P, > { - static persistedStateReducer: ?(persistedState: P, data: Object) => $Shape

; + static persistedStateReducer: ?( + persistedState: P, + method: string, + data: Object, + ) => $Shape

; static getActiveNotifications: ?(persistedState: P) => Array; constructor(props: Props<*>) { diff --git a/src/plugins/network/index.js b/src/plugins/network/index.js index b8d173821..f4c20a93e 100644 --- a/src/plugins/network/index.js +++ b/src/plugins/network/index.js @@ -121,6 +121,7 @@ export default class extends FlipperPlugin { static persistedStateReducer = ( persistedState: PersistedState, + method: string, data: Request | Response, ): PersistedState => { const dataType: 'requests' | 'responses' = data.url