|
4 | 4 | selectKnownDevices, |
5 | 5 | selectNearbyDevices, |
6 | 6 | } from '@suite-common/bluetooth'; |
7 | | -import { createWeakMapSelector } from '@suite-common/redux-utils'; |
| 7 | +import { createWeakMapSelector, returnStableArrayIfEmpty } from '@suite-common/redux-utils'; |
8 | 8 |
|
9 | 9 | import { NativeBluetoothRootState } from './bluetoothSlice'; |
10 | 10 |
|
@@ -38,22 +38,26 @@ export const selectNearbyBluetoothDevices = createMemoizedSelector( |
38 | 38 | export const selectNearbyPairableBluetoothDevices = createMemoizedSelector( |
39 | 39 | [selectNearbyBluetoothDevices, selectKnownBluetoothDevices], |
40 | 40 | (nearbyBluetoothDevices, knownBluetoothDevices) => |
41 | | - nearbyBluetoothDevices.filter( |
42 | | - ({ id, manufacturerData }) => |
43 | | - knownBluetoothDevices.every(knownDevice => knownDevice.id !== id) && |
44 | | - manufacturerData.filterPolicy?.pairing === true, |
| 41 | + returnStableArrayIfEmpty( |
| 42 | + nearbyBluetoothDevices.filter( |
| 43 | + ({ id, manufacturerData }) => |
| 44 | + knownBluetoothDevices.every(knownDevice => knownDevice.id !== id) && |
| 45 | + manufacturerData.filterPolicy?.pairing === true, |
| 46 | + ), |
45 | 47 | ), |
46 | 48 | ); |
47 | 49 |
|
48 | 50 | export const selectKnownConnectableBluetoothDevices = createMemoizedSelector( |
49 | 51 | [selectNearbyBluetoothDevices, selectKnownBluetoothDevices, selectBluetoothAutoConnectPolicy], |
50 | 52 | (nearbyBluetoothDevices, knownBluetoothDevices, autoConnectPolicy) => |
51 | | - nearbyBluetoothDevices.filter( |
52 | | - ({ id, manufacturerData, connectionStatus }) => |
53 | | - knownBluetoothDevices.some(knownDevice => knownDevice.id === id) && |
54 | | - autoConnectPolicy[id]?.type !== 'autoconnect-disabled' && |
55 | | - manufacturerData.filterPolicy?.pairing !== true && |
56 | | - manufacturerData.filterPolicy?.user_disconnected !== true && |
57 | | - connectionStatus.type === 'disconnected', |
| 53 | + returnStableArrayIfEmpty( |
| 54 | + nearbyBluetoothDevices.filter( |
| 55 | + ({ id, manufacturerData, connectionStatus }) => |
| 56 | + knownBluetoothDevices.some(knownDevice => knownDevice.id === id) && |
| 57 | + autoConnectPolicy[id]?.type !== 'autoconnect-disabled' && |
| 58 | + manufacturerData.filterPolicy?.pairing !== true && |
| 59 | + manufacturerData.filterPolicy?.user_disconnected !== true && |
| 60 | + connectionStatus.type === 'disconnected', |
| 61 | + ), |
58 | 62 | ), |
59 | 63 | ); |
0 commit comments