From 0f08b045712f55bc715abb7d7182f64fc64221f9 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 31 Aug 2018 07:58:03 -0700 Subject: [PATCH] Filter displayed plugins by selected device Summary: Now that android devices know their own serial, we can filter plugins by the selected device. Reviewed By: passy Differential Revision: D9481461 fbshipit-source-id: 4a53eea1e61caa09c3d63ca0076fbc1b6dceb99f --- src/chrome/MainSidebar.js | 60 +++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index 229b54a79..c18e7aab2 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -198,31 +198,41 @@ class MainSidebar extends Component { plugin={plugin} /> ))} - {clients.map((client: Client) => ( - - {client.query.app} - {plugins - .filter( - (p: Class>) => client.plugins.indexOf(p.id) > -1, - ) - .map((plugin: Class>) => ( - - selectPlugin({ - selectedPlugin: plugin.id, - selectedApp: client.id, - }) - } - plugin={plugin} - app={client.query.app} - /> - ))} - - ))} + {clients + .filter( + (client: Client) => + (selectedDevice && + client.query.device_id === selectedDevice.serial) || + // Old android sdk versions don't know their device_id + // Display their plugins under all selected devices until they die out + client.query.device_id === 'unknown', + ) + .map((client: Client) => ( + + {client.query.app} + {plugins + .filter( + (p: Class>) => + client.plugins.indexOf(p.id) > -1, + ) + .map((plugin: Class>) => ( + + selectPlugin({ + selectedPlugin: plugin.id, + selectedApp: client.id, + }) + } + plugin={plugin} + app={client.query.app} + /> + ))} + + ))} ); }