1+ import { bluetoothActions , selectAdapterStatus } from '@suite-common/bluetooth' ;
12import * as deviceUtils from '@suite-common/suite-utils' ;
23import { selectDevices } from '@suite-common/wallet-core' ;
34import { Button , Column } from '@trezor/components' ;
45import { spacings } from '@trezor/theme' ;
56
67import { setConnectionMode , toggleConnectionModal } from 'src/actions/device/deviceSlice' ;
8+ import { Translation } from 'src/components/suite/Translation' ;
79import { useDispatch , useSelector } from 'src/hooks/suite' ;
810import { selectSuiteFlags } from 'src/selectors/suite/suiteSelectors' ;
911import { ForegroundAppProps } from 'src/types/suite' ;
@@ -12,9 +14,9 @@ import { DeviceItem } from './DeviceItem/DeviceItem';
1214import { SwitchDeviceModal } from './SwitchDeviceModal' ;
1315
1416export const SwitchDevice = ( { cancelable, onCancel } : ForegroundAppProps ) => {
15- const { isBluetoothEnabled } = useSelector ( selectSuiteFlags ) ;
1617 const dispatch = useDispatch ( ) ;
17-
18+ const { isBluetoothEnabled } = useSelector ( selectSuiteFlags ) ;
19+ const bluetoothAdapterStatus = useSelector ( selectAdapterStatus ) ;
1820 const devices = useSelector ( selectDevices ) ;
1921
2022 // exclude selectedDevice from list, because other devices could have a higher priority,
@@ -24,8 +26,13 @@ export const SwitchDevice = ({ cancelable, onCancel }: ForegroundAppProps) => {
2426 } ) ;
2527
2628 const openDeviceConnectionModal = ( ) => {
27- dispatch ( setConnectionMode ( 'bluetooth' ) ) ;
2829 dispatch ( toggleConnectionModal ( ) ) ;
30+
31+ if ( isBluetoothEnabled && bluetoothAdapterStatus === 'enabled' ) {
32+ dispatch ( bluetoothActions . enableAutoConnect ( ) ) ;
33+ dispatch ( setConnectionMode ( 'bluetooth' ) ) ;
34+ }
35+
2936 onCancel ( ) ;
3037 } ;
3138
@@ -40,16 +47,14 @@ export const SwitchDevice = ({ cancelable, onCancel }: ForegroundAppProps) => {
4047 onCancel = { cancelable ? onCancel : undefined }
4148 />
4249 ) ) }
43- { isBluetoothEnabled && (
44- < Button
45- variant = "tertiary"
46- icon = "bluetooth"
47- isFullWidth
48- onClick = { openDeviceConnectionModal }
49- >
50- Pair Trezor Safe 7
51- </ Button >
52- ) }
50+ < Button
51+ variant = "tertiary"
52+ icon = "trezorDevices"
53+ isFullWidth
54+ onClick = { openDeviceConnectionModal }
55+ >
56+ < Translation id = "TR_CONNECT_DEVICE" />
57+ </ Button >
5358 </ Column >
5459 </ SwitchDeviceModal >
5560 ) ;
0 commit comments