connected all devices

This commit is contained in:
ashrafzarkanisala
2024-06-22 16:44:17 +03:00
parent 7c9b7fbb86
commit 1fe4603cbf
8 changed files with 169 additions and 144 deletions
@@ -16,6 +16,7 @@ import 'package:syncrow_app/features/devices/view/widgets/lights/lights_view.dar
import 'package:syncrow_app/features/devices/view/widgets/three_gang/three_gang_interface.dart';
import 'package:syncrow_app/features/devices/view/widgets/smart_door/doors_list_view.dart';
import 'package:syncrow_app/services/api/devices_api.dart';
import 'package:syncrow_app/services/api/home_management_api.dart';
import 'package:syncrow_app/services/api/network_exception.dart';
import 'package:syncrow_app/services/api/spaces_api.dart';
import 'package:syncrow_app/utils/resource_manager/constants.dart';
@@ -289,6 +290,9 @@ class DevicesCubit extends Cubit<DevicesState> {
fetchDevicesByRoomId(String? roomId) async {
if (roomId == null) return;
if (roomId == '-1') {
return fetchAllDevices();
}
emitSafe(GetDevicesLoading());
int roomIndex = HomeCubit.getInstance()
@@ -316,6 +320,16 @@ class DevicesCubit extends Cubit<DevicesState> {
// }
}
void fetchAllDevices() async {
emitSafe(GetDevicesLoading());
try {
final allDevices = await HomeManagementAPI.fetchDevicesByUserId();
emitSafe(GetDevicesSuccess(allDevices));
} catch (e) {
emitSafe(GetDevicesError(e.toString()));
}
}
fetchDevicesStatues(String deviceUuid, int roomIndex, {String? code}) async {
emitSafe(GetDeviceStatusLoading(code: code));
int deviceIndex = HomeCubit.getInstance()