ChatListBloc constructor
ChatListBloc({
- FilterChatModels? filter,
- bool? paged,
- String? orderBy,
- bool? descending,
- bool? detailed,
- EliudQuery? eliudQuery,
- required ChatRepository chatRepository,
- int chatLimit = 5,
Implementation
ChatListBloc(
{this.filter,
this.paged,
this.orderBy,
this.descending,
this.detailed,
this.eliudQuery,
required ChatRepository chatRepository,
this.chatLimit = 5})
: _chatRepository = chatRepository,
super(ChatListLoading()) {
on<LoadChatList>((event, emit) {
if ((detailed == null) || (!detailed!)) {
_mapLoadChatListToState();
} else {
_mapLoadChatListWithDetailsToState();
}
});
on<NewPage>((event, emit) {
pages = pages +
1; // it doesn't matter so much if we increase pages beyond the end
_mapLoadChatListWithDetailsToState();
});
on<ChatChangeQuery>((event, emit) {
eliudQuery = event.newQuery;
if ((detailed == null) || (!detailed!)) {
_mapLoadChatListToState();
} else {
_mapLoadChatListWithDetailsToState();
}
});
on<AddChatList>((event, emit) async {
await _mapAddChatListToState(event);
});
on<UpdateChatList>((event, emit) async {
await _mapUpdateChatListToState(event);
});
on<DeleteChatList>((event, emit) async {
await _mapDeleteChatListToState(event);
});
on<ChatListUpdated>((event, emit) {
emit(_mapChatListUpdatedToState(event));
});
}