This commit is contained in:
Faris Armoush
2025-05-22 15:53:18 +03:00
parent af4d37939b
commit 8c53d5322a

View File

@ -24,26 +24,17 @@ final class AirQualityDataLoadingStrategy implements AnalyticsDataLoadingStrateg
SpaceModel space, SpaceModel space,
) { ) {
final spaceTreeBloc = context.read<SpaceTreeBloc>(); final spaceTreeBloc = context.read<SpaceTreeBloc>();
final selectedSpacesIds = spaceTreeBloc.state.selectedSpaces; final isSpaceSelected = spaceTreeBloc.state.selectedSpaces.contains(space.uuid);
final isSpaceSelected = selectedSpacesIds.contains(space.uuid);
if (selectedSpacesIds.isEmpty) { if (isSpaceSelected) {
spaceTreeBloc.add(OnSpaceSelected(community, space.uuid ?? '', []));
} else if (isSpaceSelected) {
spaceTreeBloc.add(const SpaceTreeClearSelectionEvent());
} else {
spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent())
..add(OnSpaceSelected(community, space.uuid ?? '', []));
}
final spaceTreeState = context.read<SpaceTreeBloc>().state;
if (spaceTreeState.selectedCommunities.contains(community.uuid) ||
spaceTreeState.selectedSpaces.contains(space.uuid)) {
clearData(context); clearData(context);
return; return;
} }
spaceTreeBloc
..add(const SpaceTreeClearSelectionEvent())
..add(OnSpaceSelected(community, space.uuid ?? '', []));
FetchAirQualityDataHelper.loadAirQualityData( FetchAirQualityDataHelper.loadAirQualityData(
context, context,
communityUuid: community.uuid, communityUuid: community.uuid,