11import * as _ from 'lodash' ;
22import * as React from 'react' ;
3- import { computed , observable , action } from 'mobx' ;
4- import { observer , inject } from 'mobx-react' ;
3+ import { computed , observable , action , autorun } from 'mobx' ;
4+ import { observer , inject , disposeOnUnmount } from 'mobx-react' ;
55
66import { styled } from '../../../styles' ;
77
@@ -46,6 +46,10 @@ const ConfigContainer = styled.div`
4646 }
4747` ;
4848
49+ const AdbTargetList = styled ( InterceptionTargetList ) `
50+ max-height: 280px;
51+ ` ;
52+
4953const Footer = styled . p `
5054 font-size: 85%;
5155 font-style: italic;
@@ -81,17 +85,21 @@ class AndroidAdbConfig extends React.Component<{
8185 this . interceptDevice ( this . deviceIds [ 0 ] ) ;
8286 this . props . closeSelf ( ) ;
8387 }
88+
89+ disposeOnUnmount ( this , autorun ( ( ) => {
90+ if ( this . deviceIds ?. length === 0 ) {
91+ this . props . closeSelf ( ) ;
92+ }
93+ } ) ) ;
8494 }
8595
8696 render ( ) {
8797 return < ConfigContainer >
8898 { this . deviceIds . length > 1
8999 ? < >
90100 < p >
91- There are multiple ADB devices connected.
92- </ p >
93- < p >
94- Pick which device you'd like to intercept:
101+ There are multiple ADB devices connected. Pick which
102+ device you'd like to intercept:
95103 </ p >
96104 </ >
97105 : this . deviceIds . length === 1
@@ -115,14 +123,20 @@ class AndroidAdbConfig extends React.Component<{
115123 </ p >
116124 </ > }
117125
118- < InterceptionTargetList
126+ < AdbTargetList
119127 spinnerText = 'Waiting for Android devices to intercept...'
120128 targets = { this . deviceIds . map ( id => {
121129 const activating = this . inProgressIds . includes ( id ) ;
122130
131+ // Only new servers (1.17.0+) expose metadata.devices with names
132+ const deviceName = this . props . interceptor . metadata ?. devices ?. [ id ] . name
133+ ?? id ;
134+
123135 return {
124136 id,
125- title : `Intercept Android device ${ id } ` ,
137+ title : `Intercept Android device ${ deviceName } ${
138+ id !== deviceName ? ` (ID: ${ id } )` : ''
139+ } `,
126140 status : activating
127141 ? 'activating'
128142 : 'available' ,
@@ -131,7 +145,7 @@ class AndroidAdbConfig extends React.Component<{
131145 : id . match ( / \d + \. \d + \. \d + \. \d + : \d + / )
132146 ? < Icon icon = { [ 'fas' , 'network-wired' ] } />
133147 : < Icon icon = { [ 'fas' , 'mobile-alt' ] } /> ,
134- content : id
148+ content : deviceName
135149 } ;
136150 } ) }
137151 interceptTarget = { this . interceptDevice }
0 commit comments