From a24655e7bdfb7ec558255b38205944b46bb0db71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Mon, 9 Jul 2018 05:26:22 -0700 Subject: [PATCH] only show apps from selected OS Summary: The sidebar always showed all apps, because we don't know on which device an app is running. This filters the sidebar to only show Android apps, when an Android device is selected and only show iOS apps when an iOS device is selected. Still, we can't filter when where are more simulators with the same OS. Reviewed By: jknoxville Differential Revision: D8766007 fbshipit-source-id: dcf0db41b2c2c5dcaa2d1700343b1dd45d3d53b0 --- src/chrome/MainSidebar.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index 599090ba3..33dac7b5a 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -28,6 +28,8 @@ import {devicePlugins} from '../device-plugins/index.js'; import plugins from '../plugins/index.js'; import {selectPlugin} from '../reducers/connections.js'; import {connect} from 'react-redux'; +import AndroidDevice from '../devices/AndroidDevice.js'; +import IOSDevice from '../devices/IOSDevice.js'; const CustomClickableListItem = ClickableListItem.extends({ paddingLeft: 10, @@ -164,10 +166,18 @@ class MainSidebar extends Component { }); clients = clients - // currently we can't filter clients for a device, because all clients - // are reporting `unknown` as their deviceID, due to a change in Android's - // API. - //.filter((client: Client) => client.getDevice() === device) + .filter((client: Client) => { + if ( + (device instanceof AndroidDevice && + client.query.os.toLowerCase() !== 'android') || + (device instanceof IOSDevice && + client.query.os.toLowerCase() !== 'ios') + ) { + return false; + } else { + return true; + } + }) .sort((a, b) => (a.query.app || '').localeCompare(b.query.app)); return (