Skip to content

Commit 098b206

Browse files
feat(suite): Connect Trezor button
1 parent b8c5bf3 commit 098b206

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

packages/suite/src/support/messages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,6 +2099,10 @@ export default defineMessages({
20992099
description: 'Prompt to user to reconnect his device.',
21002100
id: 'TR_RECONNECT_YOUR_DEVICE',
21012101
},
2102+
TR_CONNECT_DEVICE: {
2103+
defaultMessage: 'Connect Trezor',
2104+
id: 'TR_CONNECT_DEVICE',
2105+
},
21022106
TR_CONNECTED: {
21032107
defaultMessage: 'Connected',
21042108
description: 'Device status',

packages/suite/src/views/suite/SwitchDevice/SwitchDevice.tsx

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import { bluetoothActions, selectAdapterStatus } from '@suite-common/bluetooth';
12
import * as deviceUtils from '@suite-common/suite-utils';
23
import { selectDevices } from '@suite-common/wallet-core';
34
import { Button, Column } from '@trezor/components';
45
import { spacings } from '@trezor/theme';
56

67
import { setConnectionMode, toggleConnectionModal } from 'src/actions/device/deviceSlice';
8+
import { Translation } from 'src/components/suite/Translation';
79
import { useDispatch, useSelector } from 'src/hooks/suite';
810
import { selectSuiteFlags } from 'src/selectors/suite/suiteSelectors';
911
import { ForegroundAppProps } from 'src/types/suite';
@@ -12,9 +14,9 @@ import { DeviceItem } from './DeviceItem/DeviceItem';
1214
import { SwitchDeviceModal } from './SwitchDeviceModal';
1315

1416
export 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

Comments
 (0)