add all devices fetch

This commit is contained in:
ashrafzarkanisala
2024-06-23 12:01:06 +03:00
parent 1fe4603cbf
commit b58af41b88
6 changed files with 48 additions and 8 deletions

View File

@ -291,7 +291,7 @@ class DevicesCubit extends Cubit<DevicesState> {
fetchDevicesByRoomId(String? roomId) async {
if (roomId == null) return;
if (roomId == '-1') {
return fetchAllDevices();
return fetchAllDevices(roomId);
}
emitSafe(GetDevicesLoading());
@ -320,13 +320,15 @@ class DevicesCubit extends Cubit<DevicesState> {
// }
}
void fetchAllDevices() async {
void fetchAllDevices(String roomId) async {
emitSafe(GetDevicesLoading());
try {
final allDevices = await HomeManagementAPI.fetchDevicesByUserId();
emitSafe(GetDevicesSuccess(allDevices));
} catch (e) {
emitSafe(GetDevicesError(e.toString()));
return;
}
}