Fix plugin to plugin deeplinking

Summary:
Plugin to plugin deeplinking was broken because the state reducer was ignoring the parameter.

This fixes it.

Reviewed By: jonathoma

Differential Revision: D19791230

fbshipit-source-id: 158b3a6278f5e634093c4284018458883e9aa5ca
This commit is contained in:
John Knox
2020-02-07 09:46:45 -08:00
committed by Facebook Github Bot
parent c62127e56a
commit 652a95b664
2 changed files with 11 additions and 2 deletions

View File

@@ -8,7 +8,7 @@
*/
import reducer from '../connections';
import {State} from '../connections';
import {State, selectPlugin} from '../connections';
import BaseDevice from '../../devices/BaseDevice';
import MacDevice from '../../devices/MacDevice';
import {FlipperDevicePlugin} from '../../plugin';
@@ -119,3 +119,11 @@ test('errors are collected on a by name basis', () => {
]
`);
});
test('selectPlugin sets deepLinkPayload correctly', () => {
const state = reducer(
undefined,
selectPlugin({selectedPlugin: 'myPlugin', deepLinkPayload: 'myPayload'}),
);
expect(state.deepLinkPayload).toBe('myPayload');
});

View File

@@ -223,7 +223,7 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
}
case 'SELECT_PLUGIN': {
const {payload} = action;
const {selectedPlugin, selectedApp} = payload;
const {selectedPlugin, selectedApp, deepLinkPayload} = payload;
const selectedDevice = payload.selectedDevice || state.selectedDevice;
if (!selectDevice) {
console.warn('Trying to select a plugin before a device was selected!');
@@ -242,6 +242,7 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
userPreferredDevice: selectedDevice
? selectedDevice.title
: state.userPreferredDevice,
deepLinkPayload: deepLinkPayload,
});
}