mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor SidebarBloc: simplify room data handling by directly using paginatedSpaces.data
This commit is contained in:
@ -41,25 +41,9 @@ class SidebarBloc extends Bloc<SidebarEvent, SidebarState> {
|
|||||||
search: _currentSearch,
|
search: _currentSearch,
|
||||||
);
|
);
|
||||||
|
|
||||||
final rooms = paginatedSpaces.data.map((space) {
|
|
||||||
return BookableSpaceModel(
|
|
||||||
uuid: space.uuid,
|
|
||||||
spaceName: space.spaceName,
|
|
||||||
virtualLocation: space.virtualLocation,
|
|
||||||
bookableConfig: BookableConfig(
|
|
||||||
uuid: space.bookableConfig.uuid,
|
|
||||||
daysAvailable: space.bookableConfig.daysAvailable,
|
|
||||||
startTime: space.bookableConfig.startTime,
|
|
||||||
endTime: space.bookableConfig.endTime,
|
|
||||||
active: space.bookableConfig.active,
|
|
||||||
points: space.bookableConfig.points,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
allRooms: rooms,
|
allRooms: paginatedSpaces.data,
|
||||||
displayedRooms: rooms,
|
displayedRooms: paginatedSpaces.data,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasMore: paginatedSpaces.hasNext,
|
hasMore: paginatedSpaces.hasNext,
|
||||||
totalPages: paginatedSpaces.totalPage,
|
totalPages: paginatedSpaces.totalPage,
|
||||||
@ -89,23 +73,7 @@ class SidebarBloc extends Bloc<SidebarEvent, SidebarState> {
|
|||||||
search: _currentSearch,
|
search: _currentSearch,
|
||||||
);
|
);
|
||||||
|
|
||||||
final newRooms = paginatedSpaces.data.map((space) {
|
final updatedRooms = [...state.allRooms, ...paginatedSpaces.data];
|
||||||
return BookableSpaceModel(
|
|
||||||
uuid: space.uuid,
|
|
||||||
spaceName: space.spaceName,
|
|
||||||
virtualLocation: space.virtualLocation,
|
|
||||||
bookableConfig: BookableConfig(
|
|
||||||
uuid: space.bookableConfig.uuid,
|
|
||||||
daysAvailable: space.bookableConfig.daysAvailable,
|
|
||||||
startTime: space.bookableConfig.startTime,
|
|
||||||
endTime: space.bookableConfig.endTime,
|
|
||||||
active: space.bookableConfig.active,
|
|
||||||
points: space.bookableConfig.points,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}).toList();
|
|
||||||
|
|
||||||
final updatedRooms = [...state.allRooms, ...newRooms];
|
|
||||||
|
|
||||||
emit(state.copyWith(
|
emit(state.copyWith(
|
||||||
allRooms: updatedRooms,
|
allRooms: updatedRooms,
|
||||||
|
Reference in New Issue
Block a user