Allow device specification for plugin deep-link
Summary: Allow optionally to provide the device title to select a plugin in. Currently, there's only support for `flipper://<app>/<plugin_id>`. This allows to add a `?device=<specifier>`. Reviewed By: mweststrate Differential Revision: D20920587 fbshipit-source-id: e7df4b510f1adfa9c2c9d072f6aebca1edb89cc0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8364e78e71
commit
98bb392d78
@@ -241,7 +241,22 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
|
||||
case 'SELECT_PLUGIN': {
|
||||
const {payload} = action;
|
||||
const {selectedPlugin, selectedApp, deepLinkPayload} = payload;
|
||||
const selectedDevice = payload.selectedDevice || state.selectedDevice;
|
||||
let selectedDevice =
|
||||
selectedApp === null
|
||||
? null
|
||||
: payload.selectedDevice || state.selectedDevice;
|
||||
if (deepLinkPayload) {
|
||||
const deepLinkParams = new URLSearchParams(deepLinkPayload || '');
|
||||
const deviceParam = deepLinkParams.get('device');
|
||||
const deviceMatch = state.devices.find((v) => v.title === deviceParam);
|
||||
if (deviceMatch) {
|
||||
selectedDevice = deviceMatch;
|
||||
} else {
|
||||
console.warn(
|
||||
`Could not find matching device "${deviceParam}" requested through deep-link.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!selectDevice) {
|
||||
console.warn('Trying to select a plugin before a device was selected!');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user