feat(chat): add chat lazy loading, send message and websocket init for notifications and new chat messages

This commit is contained in:
alex
2024-07-05 22:28:03 +03:00
parent 7514a9b75f
commit 5f88f49c71
11 changed files with 216 additions and 113 deletions

View File

@@ -13,6 +13,7 @@ import '/core/app_export.dart';
import 'package:go_router/go_router.dart';
part 'chat_select_event.dart';
part 'chat_select_state.dart';
/// A bloc that manages the state of a ChatSelect according to the event that is dispatched to it.
@@ -68,15 +69,19 @@ class ChatSelectBloc extends Bloc<ChatSelectEvent, ChatSelectState> {
if (data is Map<String, dynamic> && data.containsKey('chatRooms')) {
if (state is ChatSelectLoadedState) {
var currentState = state as ChatSelectLoadedState;
emit(currentState.copyWith(
chatSelectModelObj: currentState.chatSelectModelObj,
chatRooms: currentState.chatRooms,
),);
emit(
currentState.copyWith(
chatSelectModelObj: currentState.chatSelectModelObj,
chatRooms: currentState.chatRooms,
),
);
} else {
emit(ChatSelectLoadedState(
chatRooms: fillChatEntryList(data['chatRooms']),
//chatRooms: [],
),);
emit(
ChatSelectLoadedState(
chatRooms: fillChatEntryList(data['chatRooms']),
//chatRooms: [],
),
);
}
} else {
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку