push low connection

This commit is contained in:
ashrafzarkanisala
2024-08-04 18:15:01 +03:00
parent 28b92ec55f
commit a65c602725
2 changed files with 16 additions and 11 deletions
@@ -118,7 +118,7 @@ class SceneDevicesBody extends StatelessWidget {
},
);
} else if (state.error != null) {
return Center(child: Text(state.error!));
return const Center(child: Text('Something went wrong'));
} else {
return const SizedBox();
}
+15 -10
View File
@@ -13,22 +13,26 @@ class HomeManagementAPI {
var userId = await storage.read(key: UserModel.userUuidKey) ?? '';
List<DeviceModel> list = [];
await _httpService.get(
path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId),
showServerMessage: false,
expectedResponseModel: (json) {
json.forEach((value) {
list.add(DeviceModel.fromJson(value));
try {
await _httpService.get(
path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId),
showServerMessage: false,
expectedResponseModel: (json) {
json.forEach((value) {
list.add(DeviceModel.fromJson(value));
});
});
});
} catch (e) {
rethrow;
}
return list;
}
static Future<List<DeviceModel>> fetchDevicesByUnitId() async {
List<DeviceModel> list = [];
await _httpService.get(
path: ApiEndpoints.getDevicesByUnitId
.replaceAll("{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
path: ApiEndpoints.getDevicesByUnitId.replaceAll(
"{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
showServerMessage: false,
expectedResponseModel: (json) {
json.forEach((value) {
@@ -38,7 +42,8 @@ class HomeManagementAPI {
return list;
}
static Future<Map<String, dynamic>> assignDeviceToRoom(Map<String, String> body) async {
static Future<Map<String, dynamic>> assignDeviceToRoom(
Map<String, String> body) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.assignDeviceToRoom,