mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
Add functionality to fetch devices by room ID
Added a new method in DevicesCubit to fetch devices by room ID and updated related classes and API calls to support this functionality.
This commit is contained in:
@ -20,17 +20,13 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
// Create a private static instance variable
|
||||
static HomeCubit? _instance;
|
||||
HomeCubit._() : super(HomeInitial()) {
|
||||
if (spaces != null) {
|
||||
if (selectedSpace == null) {
|
||||
fetchSpaces().then((value) {
|
||||
if (selectedSpace != null) {
|
||||
print('selectedSpace: ${selectedSpace!.name}');
|
||||
fetchRooms(selectedSpace!);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
fetchSpaces(); // this is for the first time
|
||||
if (selectedSpace == null) {
|
||||
fetchSpaces().then((value) {
|
||||
if (selectedSpace != null) {
|
||||
print('selectedSpace: ${selectedSpace!.name}');
|
||||
fetchRooms(selectedSpace!);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
static HomeCubit getInstance() {
|
||||
@ -128,7 +124,7 @@ class HomeCubit extends Cubit<HomeState> {
|
||||
fetchRooms(SpaceModel space) async {
|
||||
emit(GetSpaceRoomsLoading());
|
||||
try {
|
||||
space.rooms = await SpacesAPI.getRooms(space.id!);
|
||||
space.rooms = await SpacesAPI.getRoomsBySpaceId(space.id!);
|
||||
if (space.rooms != null) {
|
||||
emit(GetSpaceRoomsLoaded(space.rooms!));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user