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> _getOnlyImplementedDevices(List<DeviceModel> devices) {
|
||||||
List<DeviceModel> implementedDevices = [];
|
const allowedDeviceTypes = {
|
||||||
|
|
||||||
const allowedDevices = <DeviceType>{
|
|
||||||
DeviceType.OneGang,
|
|
||||||
DeviceType.TwoGang,
|
|
||||||
DeviceType.ThreeGang,
|
|
||||||
DeviceType.AC,
|
DeviceType.AC,
|
||||||
DeviceType.DoorLock,
|
DeviceType.DoorLock,
|
||||||
DeviceType.Gateway,
|
DeviceType.Gateway,
|
||||||
DeviceType.WallSensor,
|
DeviceType.WallSensor,
|
||||||
DeviceType.CeilingSensor
|
DeviceType.CeilingSensor,
|
||||||
|
DeviceType.ThreeGang,
|
||||||
|
DeviceType.OneGang,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (final device in devices) {
|
return devices
|
||||||
final isDeviceAllowed = allowedDevices.contains(device.productType);
|
.where((device) => allowedDeviceTypes.contains(device.productType))
|
||||||
if (isDeviceAllowed) {
|
.toList();
|
||||||
implementedDevices.add(device);
|
|
||||||
}
|
|
||||||
return implementedDevices;
|
|
||||||
}
|
|
||||||
return implementedDevices;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user