-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement Bluetooth Onboarding UI feat: different 'Not the Trezor you are looking for' UI feat: implement Bluetooth Onboarding UI 2 feat: implement Bluetooth Onboarding UI feat: different 'Not the Trezor you are looking for' UI feat: implement Bluetooth Onboarding UI 2 feat: use CollapsibleBox component in Bluetooth UI fix: after rebase enable BT onboarding WIP: transport name breaking change aftr rebase
- Loading branch information
1 parent
90f9b45
commit d06f00d
Showing
31 changed files
with
1,140 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { createAction } from '@reduxjs/toolkit'; | ||
|
||
import { BluetoothDevice } from '@trezor/transport-bluetooth'; | ||
|
||
import { | ||
BluetoothScanStatus, | ||
DeviceBluetoothStatus, | ||
} from '../../reducers/bluetooth/bluetoothReducer'; | ||
|
||
export const BLUETOOTH_PREFIX = '@suite/bluetooth'; | ||
|
||
export const bluetoothAdapterEventAction = createAction( | ||
`${BLUETOOTH_PREFIX}/adapter-event`, | ||
({ isPowered }: { isPowered: boolean }) => ({ payload: { isPowered } }), | ||
); | ||
|
||
export const bluetoothDeviceListUpdate = createAction( | ||
`${BLUETOOTH_PREFIX}/device-list-update`, | ||
({ devices }: { devices: BluetoothDevice[] }) => ({ payload: { devices } }), | ||
); | ||
|
||
export const bluetoothConnectDeviceEventAction = createAction( | ||
`${BLUETOOTH_PREFIX}/device-connection-status`, | ||
({ connectionStatus, uuid }: { uuid: string; connectionStatus: DeviceBluetoothStatus }) => ({ | ||
payload: { uuid, connectionStatus }, | ||
}), | ||
); | ||
|
||
export const bluetoothScanStatusAction = createAction( | ||
`${BLUETOOTH_PREFIX}/scan-status`, | ||
({ status }: { status: BluetoothScanStatus }) => ({ payload: { status } }), | ||
); | ||
|
||
export const allBluetoothActions = { | ||
bluetoothAdapterEventAction, | ||
bluetoothDeviceListUpdate, | ||
bluetoothConnectDeviceEventAction, | ||
bluetoothScanStatusAction, | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/suite/src/actions/bluetooth/bluetoothConnectDeviceThunk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { createThunk } from '@suite-common/redux-utils'; | ||
import { bluetoothManager } from '@trezor/transport-bluetooth'; | ||
|
||
import { BLUETOOTH_PREFIX } from './bluetoothActions'; | ||
|
||
type ThunkResponse = ReturnType<typeof bluetoothManager.connectDevice>; | ||
|
||
export const bluetoothConnectDeviceThunk = createThunk<ThunkResponse, { uuid: string }, void>( | ||
`${BLUETOOTH_PREFIX}/bluetoothConnectDeviceThunk`, | ||
async ({ uuid }, { fulfillWithValue }) => { | ||
const result = await bluetoothManager.connectDevice(uuid); | ||
|
||
return fulfillWithValue(result); | ||
}, | ||
); |
13 changes: 13 additions & 0 deletions
13
packages/suite/src/actions/bluetooth/bluetoothStartScanningThunk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { createThunk } from '@suite-common/redux-utils'; | ||
import { bluetoothManager } from '@trezor/transport-bluetooth'; | ||
|
||
import { BLUETOOTH_PREFIX } from './bluetoothActions'; | ||
|
||
export const bluetoothStartScanningThunk = createThunk<void, void, void>( | ||
`${BLUETOOTH_PREFIX}/bluetoothStartScanningThunk`, | ||
_ => { | ||
// This can fail, but if there is an error we already got it from `adapter-event` | ||
// and user is informed about it (bluetooth turned-off, ...) | ||
bluetoothManager.startScan(); | ||
}, | ||
); |
12 changes: 12 additions & 0 deletions
12
packages/suite/src/actions/bluetooth/bluetoothStopScanningThunk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createThunk } from '@suite-common/redux-utils'; | ||
import { bluetoothManager } from '@trezor/transport-bluetooth'; | ||
|
||
import { BLUETOOTH_PREFIX } from './bluetoothActions'; | ||
|
||
export const bluetoothStopScanningThunk = createThunk<void, void, void>( | ||
`${BLUETOOTH_PREFIX}/bluetoothStopScanningThunk`, | ||
_ => { | ||
// This can fail, but there is nothing we can do about it | ||
bluetoothManager.stopScan(); | ||
}, | ||
); |
44 changes: 44 additions & 0 deletions
44
packages/suite/src/actions/bluetooth/initBluetoothThunk.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { createThunk } from '@suite-common/redux-utils/'; | ||
import { bluetoothManager, DeviceConnectionStatus } from '@trezor/transport-bluetooth'; | ||
import { Without } from '@trezor/type-utils'; | ||
|
||
import { | ||
BLUETOOTH_PREFIX, | ||
bluetoothAdapterEventAction, | ||
bluetoothConnectDeviceEventAction, | ||
bluetoothDeviceListUpdate, | ||
} from './bluetoothActions'; | ||
|
||
type DeviceConnectionStatusWithOptionalUuid = Without<DeviceConnectionStatus, 'uuid'> & { | ||
uuid?: string; | ||
}; | ||
|
||
export const initBluetoothThunk = createThunk<void, void, void>( | ||
`${BLUETOOTH_PREFIX}/initBluetoothThunk`, | ||
(_, { dispatch }) => { | ||
bluetoothManager.on('adapter-event', isPowered => { | ||
console.warn('adapter-event', isPowered); | ||
dispatch(bluetoothAdapterEventAction({ isPowered })); | ||
}); | ||
|
||
bluetoothManager.on('device-list-update', devices => { | ||
console.warn('device-list-update', devices); | ||
dispatch(bluetoothDeviceListUpdate({ devices })); | ||
}); | ||
|
||
bluetoothManager.on('device-connection-status', connectionStatus => { | ||
console.warn('device-connection-status', connectionStatus); | ||
const copyConnectionStatus: DeviceConnectionStatusWithOptionalUuid = { | ||
...connectionStatus, | ||
}; | ||
delete copyConnectionStatus.uuid; // So we dont pollute redux store | ||
|
||
dispatch( | ||
bluetoothConnectDeviceEventAction({ | ||
uuid: connectionStatus.uuid, | ||
connectionStatus: copyConnectionStatus, | ||
}), | ||
); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.