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) { } else if (state.error != null) {
return Center(child: Text(state.error!)); return const Center(child: Text('Something went wrong'));
} else { } else {
return const SizedBox(); return const SizedBox();
} }
+15 -10
View File
@@ -13,22 +13,26 @@ class HomeManagementAPI {
var userId = await storage.read(key: UserModel.userUuidKey) ?? ''; var userId = await storage.read(key: UserModel.userUuidKey) ?? '';
List<DeviceModel> list = []; List<DeviceModel> list = [];
await _httpService.get( try {
path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId), await _httpService.get(
showServerMessage: false, path: ApiEndpoints.getDevicesByUserId.replaceAll("{userId}", userId),
expectedResponseModel: (json) { showServerMessage: false,
json.forEach((value) { expectedResponseModel: (json) {
list.add(DeviceModel.fromJson(value)); json.forEach((value) {
list.add(DeviceModel.fromJson(value));
});
}); });
}); } catch (e) {
rethrow;
}
return list; return list;
} }
static Future<List<DeviceModel>> fetchDevicesByUnitId() async { static Future<List<DeviceModel>> fetchDevicesByUnitId() async {
List<DeviceModel> list = []; List<DeviceModel> list = [];
await _httpService.get( await _httpService.get(
path: ApiEndpoints.getDevicesByUnitId path: ApiEndpoints.getDevicesByUnitId.replaceAll(
.replaceAll("{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''), "{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
json.forEach((value) { json.forEach((value) {
@@ -38,7 +42,8 @@ class HomeManagementAPI {
return list; 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 { try {
final response = await _httpService.put( final response = await _httpService.put(
path: ApiEndpoints.assignDeviceToRoom, path: ApiEndpoints.assignDeviceToRoom,