mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-25 21:27:56 +00:00
push scene devices body with blocs. need to drop the future builder - enhancment
This commit is contained in:
@@ -291,8 +291,10 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
if (roomId == null) return;
|
||||
|
||||
emitSafe(GetDevicesLoading());
|
||||
int roomIndex =
|
||||
HomeCubit.getInstance().selectedSpace!.rooms!.indexWhere((element) => element.id == roomId);
|
||||
int roomIndex = HomeCubit.getInstance()
|
||||
.selectedSpace!
|
||||
.rooms!
|
||||
.indexWhere((element) => element.id == roomId);
|
||||
try {
|
||||
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices =
|
||||
await DevicesAPI.getDevicesByRoomId(roomId);
|
||||
@@ -300,7 +302,9 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
emitSafe(GetDevicesError(e.toString()));
|
||||
return;
|
||||
}
|
||||
emitSafe(GetDevicesSuccess());
|
||||
final devices =
|
||||
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices;
|
||||
emitSafe(GetDevicesSuccess(devices));
|
||||
|
||||
//get status for each device
|
||||
//TODO get devices status per page via page controller instead of getting all devices status at once
|
||||
@@ -329,8 +333,11 @@ class DevicesCubit extends Cubit<DevicesState> {
|
||||
emitSafe(GetDeviceStatusError(e.toString()));
|
||||
return;
|
||||
}
|
||||
HomeCubit.getInstance().selectedSpace!.rooms![roomIndex].devices![deviceIndex].status =
|
||||
statuses;
|
||||
HomeCubit.getInstance()
|
||||
.selectedSpace!
|
||||
.rooms![roomIndex]
|
||||
.devices![deviceIndex]
|
||||
.status = statuses;
|
||||
emitSafe(GetDeviceStatusSuccess(code: code));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,10 @@ class GetDeviceStatusError extends DevicesState {
|
||||
|
||||
class GetDevicesLoading extends DevicesState {}
|
||||
|
||||
class GetDevicesSuccess extends DevicesState {}
|
||||
class GetDevicesSuccess extends DevicesState {
|
||||
GetDevicesSuccess(this.devices);
|
||||
final List<DeviceModel>? devices;
|
||||
}
|
||||
|
||||
class GetDevicesError extends DevicesState {
|
||||
final String errorMsg;
|
||||
|
||||
Reference in New Issue
Block a user