mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
fixed on save issue
This commit is contained in:
@ -457,16 +457,17 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
|||||||
emit(SpaceManagementLoading());
|
emit(SpaceManagementLoading());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
final spaceTreeState = event.context.read<SpaceTreeBloc>().state;
|
||||||
|
|
||||||
final updatedSpaces =
|
final updatedSpaces =
|
||||||
await saveSpacesHierarchically(event.context, event.spaces, event.communityUuid);
|
await saveSpacesHierarchically(event.context, event.spaces, event.communityUuid);
|
||||||
|
|
||||||
final allSpaces = await _fetchSpacesForCommunity(event.communityUuid);
|
final allSpaces = await _fetchSpacesForCommunity(event.communityUuid);
|
||||||
|
|
||||||
emit(SpaceCreationSuccess(spaces: updatedSpaces));
|
emit(SpaceCreationSuccess(spaces: updatedSpaces));
|
||||||
|
|
||||||
if (previousState is SpaceManagementLoaded) {
|
if (previousState is SpaceManagementLoaded) {
|
||||||
await _updateLoadedState(
|
await _updateLoadedState(
|
||||||
event.context,
|
spaceTreeState,
|
||||||
previousState,
|
previousState,
|
||||||
allSpaces,
|
allSpaces,
|
||||||
event.communityUuid,
|
event.communityUuid,
|
||||||
@ -483,35 +484,39 @@ class SpaceManagementBloc extends Bloc<SpaceManagementEvent, SpaceManagementStat
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _updateLoadedState(
|
Future<void> _updateLoadedState(
|
||||||
BuildContext context,
|
SpaceTreeState spaceTreeState,
|
||||||
SpaceManagementLoaded previousState,
|
SpaceManagementLoaded previousState,
|
||||||
List<SpaceModel> allSpaces,
|
List<SpaceModel> allSpaces,
|
||||||
String communityUuid,
|
String communityUuid,
|
||||||
Emitter<SpaceManagementState> emit,
|
Emitter<SpaceManagementState> emit,
|
||||||
) async {
|
) async {
|
||||||
var prevSpaceModels = await fetchSpaceModels();
|
try {
|
||||||
await fetchTags();
|
var prevSpaceModels = await fetchSpaceModels();
|
||||||
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
|
||||||
final communities = spaceTreeState.searchQuery.isNotEmpty
|
|
||||||
? spaceTreeState.filteredCommunity
|
|
||||||
: spaceTreeState.communityList;
|
|
||||||
|
|
||||||
for (var community in communities) {
|
await fetchTags();
|
||||||
if (community.uuid == communityUuid) {
|
|
||||||
community.spaces = allSpaces;
|
|
||||||
_spaceTreeBloc.add(InitialEvent());
|
|
||||||
|
|
||||||
emit(SpaceManagementLoaded(
|
final communities = spaceTreeState.searchQuery.isNotEmpty
|
||||||
|
? spaceTreeState.filteredCommunity
|
||||||
|
: spaceTreeState.communityList;
|
||||||
|
|
||||||
|
for (var community in communities) {
|
||||||
|
if (community.uuid == communityUuid) {
|
||||||
|
community.spaces = allSpaces;
|
||||||
|
_spaceTreeBloc.add(InitialEvent());
|
||||||
|
|
||||||
|
emit(SpaceManagementLoaded(
|
||||||
communities: communities,
|
communities: communities,
|
||||||
products: _cachedProducts ?? [],
|
products: _cachedProducts ?? [],
|
||||||
selectedCommunity: community,
|
selectedCommunity: community,
|
||||||
selectedSpace: null,
|
selectedSpace: null,
|
||||||
spaceModels: prevSpaceModels,
|
spaceModels: prevSpaceModels,
|
||||||
allTags: _cachedTags ?? []));
|
allTags: _cachedTags ?? [],
|
||||||
return;
|
));
|
||||||
} else {
|
return;
|
||||||
print("Community not found");
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e, stackTrace) {
|
||||||
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user