Skip to content

Commit

Permalink
device-connection-status to device-update
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Feb 26, 2025
1 parent 710dfd1 commit 6929adb
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions packages/suite/src/actions/bluetooth/initBluetoothThunk.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { BLUETOOTH_PREFIX, bluetoothActions, selectKnownDevices } from '@suite-common/bluetooth';
import { createThunk } from '@suite-common/redux-utils/';
import { BluetoothDevice, DeviceConnectionStatus, bluetoothIpc } from '@trezor/transport-bluetooth';
import { Without } from '@trezor/type-utils';
import { BluetoothDevice, bluetoothIpc } from '@trezor/transport-bluetooth';

import { remapKnownDevicesForLinux } from './remapKnownDevicesForLinux';
import { selectSuiteFlags } from '../../reducers/suite/suiteReducer';

type DeviceConnectionStatusWithOptionalId = Without<DeviceConnectionStatus, 'id'> & {
id?: string;
};

export const initBluetoothThunk = createThunk<void, void, void>(
`${BLUETOOTH_PREFIX}/initBluetoothThunk`,
async (_, { dispatch, getState }) => {
Expand Down Expand Up @@ -40,17 +35,13 @@ export const initBluetoothThunk = createThunk<void, void, void>(
dispatch(bluetoothActions.nearbyDevicesUpdateAction({ nearbyDevices }));
});

bluetoothIpc.on('device-connection-status', connectionStatus => {
console.warn('device-connection-status', connectionStatus);
const copyConnectionStatus: DeviceConnectionStatusWithOptionalId = {
...connectionStatus,
};
delete copyConnectionStatus.id; // So we dont pollute redux store
bluetoothIpc.on('device-update', device => {
console.warn('device-update', device);

dispatch(
bluetoothActions.connectDeviceEventAction({
id: connectionStatus.id,
connectionStatus: copyConnectionStatus,
id: device.id,
connectionStatus: device.connectionStatus as any, // TODO: type
}),
);
});
Expand Down

0 comments on commit 6929adb

Please sign in to comment.