mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-27 13:34:55 +00:00
removed logs
This commit is contained in:
@ -274,15 +274,11 @@ class HomeCubit extends Cubit<HomeState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchRoomsByUnitId(SpaceModel space) async {
|
fetchRoomsByUnitId(SpaceModel space) async {
|
||||||
print("Community ID: ${space.community.uuid}");
|
|
||||||
print("Space ID: ${space.id}");
|
|
||||||
|
|
||||||
emitSafe(GetSpaceRoomsLoading());
|
emitSafe(GetSpaceRoomsLoading());
|
||||||
try {
|
try {
|
||||||
space.subspaces =
|
space.subspaces =
|
||||||
await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
|
await SpacesAPI.getSubSpaceBySpaceId(space.community.uuid, space.id);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
print("Error fetching subspaces: $failure");
|
|
||||||
|
|
||||||
emitSafe(GetSpaceRoomsError(failure.toString()));
|
emitSafe(GetSpaceRoomsError(failure.toString()));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ class SubSpaceModel {
|
|||||||
return {
|
return {
|
||||||
'id': id,
|
'id': id,
|
||||||
'name': name,
|
'name': name,
|
||||||
'devices': devices,
|
'devices': devices?.map((device) => device.toJson()).toList(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,8 +28,8 @@ class SubSpaceModel {
|
|||||||
}
|
}
|
||||||
return SubSpaceModel(
|
return SubSpaceModel(
|
||||||
id: json['uuid'],
|
id: json['uuid'],
|
||||||
name: json['name'],
|
name: json['subspaceName'],
|
||||||
devices: [],
|
devices: devices,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,24 +31,35 @@ class SpacesAPI {
|
|||||||
|
|
||||||
static Future<List<SubSpaceModel>> getSubSpaceBySpaceId(
|
static Future<List<SubSpaceModel>> getSubSpaceBySpaceId(
|
||||||
String communityId, String spaceId) async {
|
String communityId, String spaceId) async {
|
||||||
|
try {
|
||||||
|
// Construct the API path
|
||||||
final path = ApiEndpoints.listSubspace
|
final path = ApiEndpoints.listSubspace
|
||||||
.replaceFirst('{communityUuid}', communityId)
|
.replaceFirst('{communityUuid}', communityId)
|
||||||
.replaceFirst('{spaceUuid}', spaceId);
|
.replaceFirst('{spaceUuid}', spaceId);
|
||||||
print("Constructed path: $path");
|
|
||||||
|
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: path,
|
path: path,
|
||||||
queryParameters: {"page": 1, "pageSize": 10},
|
queryParameters: {"page": 1, "pageSize": 10},
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
|
|
||||||
List<SubSpaceModel> rooms = [];
|
List<SubSpaceModel> rooms = [];
|
||||||
for (var room in json['children']) {
|
if (json['data'] != null) {
|
||||||
rooms.add(SubSpaceModel.fromJson(room));
|
for (var subspace in json['data']) {
|
||||||
|
rooms.add(SubSpaceModel.fromJson(subspace));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print("Warning: 'data' key is missing or null in response JSON.");
|
||||||
}
|
}
|
||||||
return rooms;
|
return rooms;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
} catch (error, stackTrace) {
|
||||||
|
return []; // Return an empty list if there's an error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> generateInvitationCode(
|
static Future<String> generateInvitationCode(
|
||||||
|
|||||||
Reference in New Issue
Block a user