mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:49:40 +00:00
Refactor device filtering logic to improve code readability
This commit is contained in:
@ -170,26 +170,18 @@ class DeviceManagerBloc extends Bloc<DeviceManagerEvent, DeviceManagerState> {
|
||||
}
|
||||
|
||||
List<DeviceModel> _getOnlyImplementedDevices(List<DeviceModel> devices) {
|
||||
List<DeviceModel> implementedDevices = [];
|
||||
|
||||
const allowedDevices = <DeviceType>{
|
||||
DeviceType.OneGang,
|
||||
DeviceType.TwoGang,
|
||||
DeviceType.ThreeGang,
|
||||
const allowedDeviceTypes = {
|
||||
DeviceType.AC,
|
||||
DeviceType.DoorLock,
|
||||
DeviceType.Gateway,
|
||||
DeviceType.WallSensor,
|
||||
DeviceType.CeilingSensor
|
||||
DeviceType.CeilingSensor,
|
||||
DeviceType.ThreeGang,
|
||||
DeviceType.OneGang,
|
||||
};
|
||||
|
||||
for (final device in devices) {
|
||||
final isDeviceAllowed = allowedDevices.contains(device.productType);
|
||||
if (isDeviceAllowed) {
|
||||
implementedDevices.add(device);
|
||||
}
|
||||
return implementedDevices;
|
||||
}
|
||||
return implementedDevices;
|
||||
return devices
|
||||
.where((device) => allowedDeviceTypes.contains(device.productType))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user