mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fixed update space
This commit is contained in:
@ -431,11 +431,15 @@ class SpaceManagementBloc
|
||||
for (var space in orderedSpaces) {
|
||||
try {
|
||||
if (space.uuid != null && space.uuid!.isNotEmpty) {
|
||||
List<TagModelUpdate> tagUpdates = [];
|
||||
|
||||
final prevSpace = await _api.getSpace(communityUuid, space.uuid!);
|
||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
||||
final List<SubspaceModel>? newSubspaces = space.subspaces;
|
||||
|
||||
tagUpdates = processTagUpdates(prevSpace?.tags, space.tags);
|
||||
|
||||
if (prevSubspaces != null || newSubspaces != null) {
|
||||
if (prevSubspaces != null && newSubspaces != null) {
|
||||
for (var prevSubspace in prevSubspaces) {
|
||||
@ -497,6 +501,18 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
final response = await _api.updateSpace(
|
||||
communityId: communityUuid,
|
||||
spaceId: space.uuid!,
|
||||
name: space.name,
|
||||
parentId: space.parent?.uuid,
|
||||
isPrivate: space.isPrivate,
|
||||
position: space.position,
|
||||
icon: space.icon,
|
||||
subspaces: subspaceUpdates,
|
||||
tags: tagUpdates,
|
||||
direction: space.incomingConnection?.direction,
|
||||
);
|
||||
} else {
|
||||
// Call create if the space does not have a UUID
|
||||
final List<CreateTagBodyModel> tagBodyModels = space.tags != null
|
||||
@ -514,7 +530,6 @@ class SpaceManagementBloc
|
||||
}).toList() ??
|
||||
[];
|
||||
|
||||
|
||||
final response = await _api.createSpace(
|
||||
communityId: communityUuid,
|
||||
name: space.name,
|
||||
@ -596,7 +611,7 @@ class SpaceManagementBloc
|
||||
}
|
||||
}
|
||||
|
||||
List<TagModelUpdate> processTagUpdates(
|
||||
List<TagModelUpdate> processTagUpdates(
|
||||
List<Tag>? prevTags,
|
||||
List<Tag>? newTags,
|
||||
) {
|
||||
@ -670,5 +685,4 @@ class SpaceManagementBloc
|
||||
|
||||
return tagUpdates;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user