mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 18:16:34 +00:00
edits with faris and main task to fix loading state forever and prevent rethrow exceptions without catching them
This commit is contained in:
@ -478,8 +478,11 @@ class SpaceManagementBloc
|
|||||||
event.context, event.spaces, event.communityUuid);
|
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));
|
||||||
|
// updatedSpaces.forEach(
|
||||||
|
// (element) => element.uuid,
|
||||||
|
// );
|
||||||
|
// final lastUpdatedSpaced = updatedSpaces..addAll(allSpaces);
|
||||||
if (previousState is SpaceManagementLoaded) {
|
if (previousState is SpaceManagementLoaded) {
|
||||||
await _updateLoadedState(
|
await _updateLoadedState(
|
||||||
spaceTreeState,
|
spaceTreeState,
|
||||||
@ -490,7 +493,7 @@ class SpaceManagementBloc
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(SpaceManagementError('Error saving spaces: $e'));
|
// emit(SpaceManagementError('Error saving spaces: $e'));
|
||||||
|
|
||||||
if (previousState is SpaceManagementLoaded) {
|
if (previousState is SpaceManagementLoaded) {
|
||||||
emit(previousState);
|
emit(previousState);
|
||||||
@ -530,8 +533,10 @@ class SpaceManagementBloc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emit(previousState);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
rethrow;
|
emit(previousState);
|
||||||
|
// rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -549,6 +554,14 @@ class SpaceManagementBloc
|
|||||||
|
|
||||||
selectedCommunity = filteredCommunities.firstWhere(
|
selectedCommunity = filteredCommunities.firstWhere(
|
||||||
(community) => community.uuid == communityUuid,
|
(community) => community.uuid == communityUuid,
|
||||||
|
orElse: () => CommunityModel(
|
||||||
|
uuid: '',
|
||||||
|
createdAt: DateTime.now(),
|
||||||
|
updatedAt: DateTime.now(),
|
||||||
|
name: '',
|
||||||
|
description: '',
|
||||||
|
spaces: spaces,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return [];
|
return [];
|
||||||
@ -563,9 +576,7 @@ class SpaceManagementBloc
|
|||||||
if (parent.uuid != null) {
|
if (parent.uuid != null) {
|
||||||
await _api.deleteSpace(communityUuid, parent.uuid!, projectUuid);
|
await _api.deleteSpace(communityUuid, parent.uuid!, projectUuid);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
orderedSpaces.removeWhere((space) => parentsToDelete.contains(space));
|
orderedSpaces.removeWhere((space) => parentsToDelete.contains(space));
|
||||||
|
|
||||||
@ -579,7 +590,7 @@ class SpaceManagementBloc
|
|||||||
|
|
||||||
if (matchedSpaces.isEmpty) continue;
|
if (matchedSpaces.isEmpty) continue;
|
||||||
|
|
||||||
final prevSpace = matchedSpaces[0];
|
final prevSpace = matchedSpaces.elementAtOrNull(0);
|
||||||
|
|
||||||
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
final List<UpdateSubspaceTemplateModel> subspaceUpdates = [];
|
||||||
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
final List<SubspaceModel>? prevSubspaces = prevSpace?.subspaces;
|
||||||
@ -658,8 +669,10 @@ class SpaceManagementBloc
|
|||||||
isPrivate: space.isPrivate,
|
isPrivate: space.isPrivate,
|
||||||
position: space.position,
|
position: space.position,
|
||||||
icon: space.icon,
|
icon: space.icon,
|
||||||
subspaces: subspaceUpdates,
|
subspaces: space.subspaces,
|
||||||
tags: tagUpdates,
|
// subspaceUpdates,
|
||||||
|
tags: space.tags,
|
||||||
|
// tagUpdates,
|
||||||
spaceModelUuid: space.spaceModel?.uuid,
|
spaceModelUuid: space.spaceModel?.uuid,
|
||||||
projectId: projectUuid);
|
projectId: projectUuid);
|
||||||
} else {
|
} else {
|
||||||
@ -698,7 +711,8 @@ class SpaceManagementBloc
|
|||||||
space.uuid = response?.uuid;
|
space.uuid = response?.uuid;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
rethrow; // Stop further execution on failure
|
return [];
|
||||||
|
// Stop further execution on failure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return spaces;
|
return spaces;
|
||||||
|
Reference in New Issue
Block a user