mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
added update in space tree bloc
This commit is contained in:
@ -16,6 +16,7 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
on<SearchQueryEvent>(_onSearch);
|
||||
on<ClearAllData>(_clearAllData);
|
||||
on<ClearCachedData>(_clearCachedData);
|
||||
on<OnCommunityAdded>(_onCommunityAdded);
|
||||
}
|
||||
|
||||
_fetchSpaces(InitialEvent event, Emitter<SpaceTreeState> emit) async {
|
||||
@ -50,6 +51,14 @@ class SpaceTreeBloc extends Bloc<SpaceTreeEvent, SpaceTreeState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _onCommunityAdded(OnCommunityAdded event, Emitter<SpaceTreeState> emit) async {
|
||||
final updatedCommunities = List<CommunityModel>.from(state.communityList);
|
||||
updatedCommunities.add(event.newCommunity);
|
||||
|
||||
emit(state.copyWith(communitiesList: updatedCommunities));
|
||||
}
|
||||
|
||||
|
||||
_onCommunityExpanded(OnCommunityExpanded event, Emitter<SpaceTreeState> emit) async {
|
||||
try {
|
||||
List<String> updatedExpandedCommunityList = List.from(state.expandedCommunities);
|
||||
|
@ -69,6 +69,14 @@ class SearchQueryEvent extends SpaceTreeEvent {
|
||||
List<Object> get props => [searchQuery];
|
||||
}
|
||||
|
||||
class OnCommunityAdded extends SpaceTreeEvent {
|
||||
final CommunityModel newCommunity;
|
||||
const OnCommunityAdded(this.newCommunity);
|
||||
|
||||
@override
|
||||
List<Object> get props => [newCommunity];
|
||||
}
|
||||
|
||||
class ClearAllData extends SpaceTreeEvent {}
|
||||
|
||||
class ClearCachedData extends SpaceTreeEvent {}
|
||||
|
Reference in New Issue
Block a user