@@ -147,7 +147,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
147
147
return this . _features ;
148
148
}
149
149
150
- private _featuresNeedsReload = false ;
150
+ private wasUsedElsewhere = false ;
151
151
152
152
// variables used in one workflow: acquire -> transportSession -> commands -> run -> keepTransportSession -> release
153
153
private acquirePromise ?: ReturnType < Transport [ 'acquire' ] > ;
@@ -272,6 +272,7 @@ export class Device extends TypedEmitter<DeviceEvents> {
272
272
. then ( result => this . waitAndCompareSession ( result , sessionPromise ) )
273
273
. then ( result => {
274
274
if ( result . success ) {
275
+ this . wasUsedElsewhere = false ;
275
276
this . sessionAcquired = result . payload ;
276
277
this . currentSession = new DeviceCurrentSession (
277
278
this ,
@@ -446,6 +447,8 @@ export class Device extends TypedEmitter<DeviceEvents> {
446
447
}
447
448
448
449
private usedElsewhere ( ) {
450
+ this . wasUsedElsewhere = true ;
451
+
449
452
// only makes sense to continue when device held by this instance
450
453
if ( ! this . sessionAcquired ) {
451
454
return ;
@@ -457,8 +460,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
457
460
this . transport . releaseDevice ( this . sessionAcquired ) ;
458
461
this . sessionAcquired = null ;
459
462
460
- this . _featuresNeedsReload = true ;
461
-
462
463
_log . debug ( 'interruptionFromOutside' ) ;
463
464
464
465
this . runAbort ?. abort ( ERRORS . TypedError ( 'Device_UsedElsewhere' ) ) ;
@@ -944,7 +945,6 @@ export class Device extends TypedEmitter<DeviceEvents> {
944
945
}
945
946
946
947
this . _features = feat ;
947
- this . _featuresNeedsReload = false ;
948
948
949
949
// Vendor headers have been changed in 2.6.3.
950
950
if ( feat . fw_vendor === 'Trezor Bitcoin-only' ) {
@@ -1137,8 +1137,9 @@ export class Device extends TypedEmitter<DeviceEvents> {
1137
1137
const defaultLabel = 'My Trezor' ;
1138
1138
const label =
1139
1139
this . features . label === '' || ! this . features . label ? defaultLabel : this . features . label ;
1140
- let status : DeviceStatus = this . isUsedElsewhere ( ) ? 'occupied' : 'available' ;
1141
- if ( this . _featuresNeedsReload ) status = 'used' ;
1140
+ const status : DeviceStatus = this . isUsedElsewhere ( )
1141
+ ? 'occupied'
1142
+ : ( this . wasUsedElsewhere && 'used' ) || 'available' ;
1142
1143
1143
1144
return {
1144
1145
...base ,
0 commit comments