@@ -35,19 +35,21 @@ export class ClientViewModel extends ViewModel {
35
35
this . _pickClient = pickClient ;
36
36
// to provide "choose other client" button after calling pick()
37
37
this . _clientListViewModel = null ;
38
+ this . _update ( ) ;
39
+ }
38
40
39
- const matchingPlatforms = getMatchingPlatforms ( client , this . platforms ) ;
40
- const nativePlatform = matchingPlatforms . find ( p => ! isWebPlatform ( p ) ) ;
41
+ _update ( ) {
42
+ const matchingPlatforms = getMatchingPlatforms ( this . _client , this . platforms ) ;
41
43
const webPlatform = matchingPlatforms . find ( p => isWebPlatform ( p ) ) ;
42
-
43
- this . _proposedPlatform = this . preferences . platform || nativePlatform || webPlatform ;
44
- this . _nativePlatform = nativePlatform || this . _proposedPlatform ;
44
+ this . _nativePlatform = matchingPlatforms . find ( p => ! isWebPlatform ( p ) ) ;
45
+ this . _proposedPlatform = this . preferences . platform || this . _nativePlatform || webPlatform ;
45
46
46
- this . actions = this . _createActions ( client , link , nativePlatform , webPlatform ) ;
47
- this . _clientCanIntercept = ! ! ( nativePlatform && client . canInterceptMatrixToLinks ( nativePlatform ) ) ;
47
+ this . actions = this . _createActions ( this . _client , this . _link , this . _nativePlatform , webPlatform ) ;
48
+ this . _clientCanIntercept = ! ! ( this . _nativePlatform && this . _client . canInterceptMatrixToLinks ( this . _nativePlatform ) ) ;
48
49
this . _showOpen = this . deepLink && ! this . _clientCanIntercept ;
49
- }
50
+ }
50
51
52
+ // these are only shown in the install stage
51
53
_createActions ( client , link , nativePlatform , webPlatform ) {
52
54
let actions = [ ] ;
53
55
if ( nativePlatform ) {
@@ -117,7 +119,8 @@ export class ClientViewModel extends ViewModel {
117
119
}
118
120
119
121
get showDeepLinkInInstall ( ) {
120
- return this . _clientCanIntercept && this . deepLink ;
122
+ // we can assume this._nativePlatform as this._clientCanIntercept already checks it
123
+ return this . _clientCanIntercept && ! ! this . _client . getDeepLink ( this . _nativePlatform , this . _link ) ;
121
124
}
122
125
123
126
get availableOnPlatformNames ( ) {
@@ -142,14 +145,20 @@ export class ClientViewModel extends ViewModel {
142
145
return textPlatforms ;
143
146
}
144
147
148
+ get _deepLinkPlatform ( ) {
149
+ // in install stage, always show the native link in the small "open it here" link, independent of preference.
150
+ return this . _showOpen ? this . _proposedPlatform : this . _nativePlatform ;
151
+ }
152
+
153
+ // both used for big "Continue" button in open stage,
154
+ // and for small "open it here" link in the install stage.
145
155
get deepLink ( ) {
146
- const platform = this . showBack ? this . _proposedPlatform : this . _nativePlatform ;
147
- return this . _client . getDeepLink ( platform , this . _link ) ;
156
+ return this . _client . getDeepLink ( this . _deepLinkPlatform , this . _link ) ;
148
157
}
149
158
150
159
deepLinkActivated ( ) {
151
160
this . _pickClient ( this . _client ) ;
152
- this . preferences . setClient ( this . _client . id , this . _proposedPlatform ) ;
161
+ this . preferences . setClient ( this . _client . id , this . _deepLinkPlatform ) ;
153
162
if ( this . _showOpen ) {
154
163
this . _showOpen = false ;
155
164
this . emitChange ( ) ;
@@ -161,15 +170,20 @@ export class ClientViewModel extends ViewModel {
161
170
this . emitChange ( ) ;
162
171
}
163
172
173
+ // whether or not we are only showing this client (in open or install stage)
164
174
get showBack ( ) {
165
- // if we're not only showing this client, don't show back (see pick())
166
175
return ! ! this . _clientListViewModel ;
167
176
}
168
177
169
178
back ( ) {
170
179
if ( this . _clientListViewModel ) {
171
180
const vm = this . _clientListViewModel ;
172
181
this . _clientListViewModel = null ;
182
+ // clear the client preference so we default back to to native link if any
183
+ // in the list with all clients, and also if we refresh, we get the list with
184
+ // all clients rather than having our "change client" click reverted.
185
+ this . preferences . setClient ( undefined , undefined ) ;
186
+ this . _update ( ) ;
173
187
this . emitChange ( ) ;
174
188
vm . showAll ( ) ;
175
189
}
0 commit comments