1
1
import * as _ from 'lodash' ;
2
2
import * 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' ;
5
5
6
6
import { styled } from '../../../styles' ;
7
7
@@ -46,6 +46,10 @@ const ConfigContainer = styled.div`
46
46
}
47
47
` ;
48
48
49
+ const AdbTargetList = styled ( InterceptionTargetList ) `
50
+ max-height: 280px;
51
+ ` ;
52
+
49
53
const Footer = styled . p `
50
54
font-size: 85%;
51
55
font-style: italic;
@@ -81,17 +85,21 @@ class AndroidAdbConfig extends React.Component<{
81
85
this . interceptDevice ( this . deviceIds [ 0 ] ) ;
82
86
this . props . closeSelf ( ) ;
83
87
}
88
+
89
+ disposeOnUnmount ( this , autorun ( ( ) => {
90
+ if ( this . deviceIds ?. length === 0 ) {
91
+ this . props . closeSelf ( ) ;
92
+ }
93
+ } ) ) ;
84
94
}
85
95
86
96
render ( ) {
87
97
return < ConfigContainer >
88
98
{ this . deviceIds . length > 1
89
99
? < >
90
100
< 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:
95
103
</ p >
96
104
</ >
97
105
: this . deviceIds . length === 1
@@ -115,14 +123,20 @@ class AndroidAdbConfig extends React.Component<{
115
123
</ p >
116
124
</ > }
117
125
118
- < InterceptionTargetList
126
+ < AdbTargetList
119
127
spinnerText = 'Waiting for Android devices to intercept...'
120
128
targets = { this . deviceIds . map ( id => {
121
129
const activating = this . inProgressIds . includes ( id ) ;
122
130
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
+
123
135
return {
124
136
id,
125
- title : `Intercept Android device ${ id } ` ,
137
+ title : `Intercept Android device ${ deviceName } ${
138
+ id !== deviceName ? ` (ID: ${ id } )` : ''
139
+ } `,
126
140
status : activating
127
141
? 'activating'
128
142
: 'available' ,
@@ -131,7 +145,7 @@ class AndroidAdbConfig extends React.Component<{
131
145
: id . match ( / \d + \. \d + \. \d + \. \d + : \d + / )
132
146
? < Icon icon = { [ 'fas' , 'network-wired' ] } />
133
147
: < Icon icon = { [ 'fas' , 'mobile-alt' ] } /> ,
134
- content : id
148
+ content : deviceName
135
149
} ;
136
150
} ) }
137
151
interceptTarget = { this . interceptDevice }
0 commit comments