forked from eatvio/eatvio_app
refactor(go_router): add pages to go router, fix screens
This commit is contained in:
@@ -9,7 +9,9 @@ import 'dart:convert';
|
||||
import '/core/app_export.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_screen/models/chat_model.dart';
|
||||
import 'package:eatvio_app/presentation/chat/chat_screen/models/chat_message_model.dart';
|
||||
|
||||
part 'chat_event.dart';
|
||||
|
||||
part 'chat_state.dart';
|
||||
|
||||
/// A bloc that manages the state of a Chat according to the event that is dispatched to it.
|
||||
@@ -37,17 +39,12 @@ class ChatBloc extends Bloc<ChatEvent, ChatState> {
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
final data = jsonDecode(response.body);
|
||||
if (data is Map<String, dynamic> &&
|
||||
data.containsKey('chatRoom') &&
|
||||
data['chatRoom'].containsKey('messages')) {
|
||||
if (data is Map<String, dynamic> && data.containsKey('chatRoom') && data['chatRoom'].containsKey('messages')) {
|
||||
if (state is ChatLoadedState) {
|
||||
var currentState = state as ChatLoadedState;
|
||||
emit(currentState.copyWith(
|
||||
chatModelObj: currentState.chatModelObj,
|
||||
messages: currentState.messages));
|
||||
emit(currentState.copyWith(chatModelObj: currentState.chatModelObj, messages: currentState.messages));
|
||||
} else {
|
||||
emit(ChatLoadedState(
|
||||
messages: fillMessages(data['chatRoom']['messages'])));
|
||||
emit(ChatLoadedState(messages: fillMessages(data['chatRoom']['messages'])));
|
||||
}
|
||||
} else {
|
||||
// Один или несколько ключевых полей отсутствуют, обрабатываем ошибку
|
||||
|
||||
Reference in New Issue
Block a user