mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
save only if there is a change or new space
This commit is contained in:
@ -193,6 +193,9 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
void _updateNodePosition(SpaceModel node, Offset newPosition) {
|
||||
setState(() {
|
||||
node.position = newPosition;
|
||||
if (node.status != SpaceStatus.newSpace) {
|
||||
node.status = SpaceStatus.modified; // Mark as modified
|
||||
}
|
||||
if (node.position.dx >= canvasWidth - 200) {
|
||||
canvasWidth += 200;
|
||||
}
|
||||
@ -244,6 +247,7 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
position: centerPosition,
|
||||
isPrivate: false,
|
||||
children: [],
|
||||
status: SpaceStatus.newSpace,
|
||||
);
|
||||
|
||||
if (parentIndex != null && direction != null) {
|
||||
@ -330,14 +334,21 @@ class _CommunityStructureAreaState extends State<CommunityStructureArea> {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prepare spaces and connections data
|
||||
List<SpaceModel> spaceList = spaces;
|
||||
List<SpaceModel> spacesToSave = spaces.where((space) {
|
||||
return space.status == SpaceStatus.newSpace || space.status == SpaceStatus.modified;
|
||||
}).toList();
|
||||
|
||||
if (spacesToSave.isEmpty) {
|
||||
print("No new or modified spaces to save.");
|
||||
return;
|
||||
}
|
||||
|
||||
String communityUuid = widget.selectedCommunity!.uuid;
|
||||
|
||||
// Dispatch the save event
|
||||
context.read<SpaceManagementBloc>().add(SaveSpacesEvent(
|
||||
spaces: spaceList,
|
||||
spaces: spacesToSave,
|
||||
communityUuid: communityUuid,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user