mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
resets selection and clears data.
This commit is contained in:
@ -14,12 +14,20 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
CommunityModel community,
|
CommunityModel community,
|
||||||
List<SpaceModel> spaces,
|
List<SpaceModel> spaces,
|
||||||
) {
|
) {
|
||||||
|
// Add to space tree bloc first
|
||||||
context.read<SpaceTreeBloc>().add(
|
context.read<SpaceTreeBloc>().add(
|
||||||
OnCommunitySelected(
|
OnCommunitySelected(
|
||||||
community.uuid,
|
community.uuid,
|
||||||
spaces,
|
spaces,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||||
|
if (spaceTreeState.selectedCommunities.contains(community.uuid)) {
|
||||||
|
clearData(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FetchEnergyManagementDataHelper.loadEnergyManagementData(
|
FetchEnergyManagementDataHelper.loadEnergyManagementData(
|
||||||
context,
|
context,
|
||||||
communityId: community.uuid,
|
communityId: community.uuid,
|
||||||
@ -41,6 +49,13 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||||
|
if (spaceTreeState.selectedCommunities.contains(community.uuid) ||
|
||||||
|
spaceTreeState.selectedSpaces.contains(space.uuid)) {
|
||||||
|
clearData(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FetchEnergyManagementDataHelper.loadEnergyManagementData(
|
FetchEnergyManagementDataHelper.loadEnergyManagementData(
|
||||||
context,
|
context,
|
||||||
communityId: community.uuid,
|
communityId: community.uuid,
|
||||||
@ -54,7 +69,7 @@ class EnergyManagementDataLoadingStrategy implements AnalyticsDataLoadingStrateg
|
|||||||
CommunityModel community,
|
CommunityModel community,
|
||||||
SpaceModel child,
|
SpaceModel child,
|
||||||
) {
|
) {
|
||||||
// Do nothing
|
// Do nothing else as per original implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -20,6 +20,12 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
|||||||
spaces.isNotEmpty ? [spaces.first] : [],
|
spaces.isNotEmpty ? [spaces.first] : [],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||||
|
if (spaceTreeState.selectedCommunities.contains(community.uuid)) {
|
||||||
|
clearData(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
FetchOccupancyDataHelper.loadOccupancyData(
|
FetchOccupancyDataHelper.loadOccupancyData(
|
||||||
context,
|
context,
|
||||||
communityId: community.uuid,
|
communityId: community.uuid,
|
||||||
@ -47,6 +53,13 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
|||||||
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
..add(OnSpaceSelected(community, space.uuid ?? '', []));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final spaceTreeState = context.read<SpaceTreeBloc>().state;
|
||||||
|
if (spaceTreeState.selectedCommunities.contains(community.uuid) ||
|
||||||
|
spaceTreeState.selectedSpaces.contains(space.uuid)) {
|
||||||
|
clearData(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FetchOccupancyDataHelper.loadOccupancyData(
|
FetchOccupancyDataHelper.loadOccupancyData(
|
||||||
context,
|
context,
|
||||||
communityId: community.uuid,
|
communityId: community.uuid,
|
||||||
@ -66,6 +79,6 @@ class OccupancyDataLoadingStrategy implements AnalyticsDataLoadingStrategy {
|
|||||||
@override
|
@override
|
||||||
void clearData(BuildContext context) {
|
void clearData(BuildContext context) {
|
||||||
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent());
|
context.read<SpaceTreeBloc>().add(const SpaceTreeClearSelectionEvent());
|
||||||
// FetchOccupancyDataHelper.clearAllData(context);
|
FetchOccupancyDataHelper.clearAllData(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,24 @@ class AnalyticsCommunitiesSidebar extends StatelessWidget {
|
|||||||
|
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: AnalyticsSpaceTreeView(
|
child: AnalyticsSpaceTreeView(
|
||||||
onSelectCommunity: (community, spaces) {
|
onSelectCommunity: (community, spaces) async {
|
||||||
strategy.onCommunitySelected(context, community, spaces);
|
await Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
strategy.onCommunitySelected(context, community, spaces);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onSelectSpace: (community, space) {
|
onSelectSpace: (community, space) async {
|
||||||
strategy.onSpaceSelected(context, community, space);
|
await Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
strategy.onSpaceSelected(context, community, space);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onSelectChildSpace: (community, child) {
|
onSelectChildSpace: (community, child) async {
|
||||||
strategy.onChildSpaceSelected(context, community, child);
|
await Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
|
if (!context.mounted) return;
|
||||||
|
strategy.onChildSpaceSelected(context, community, child);
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user