feat(chat): add init and dispose chat, typing info, receive a messages

This commit is contained in:
alex
2024-07-03 16:50:09 +03:00
parent 424ce3cb34
commit 4c7519ee4c
27 changed files with 553 additions and 167 deletions

View File

@@ -1,3 +1,4 @@
import 'package:eatvio_app/features/chat/models/chat_messages_model.dart';
import 'package:eatvio_app/features/chat/models/chat_room_model.dart';
import 'package:eatvio_app/features/chat/models/websocket_info_model.dart';
import 'package:eatvio_app/features/chat/services/chat_service.dart';
@@ -9,23 +10,30 @@ class ChatRepository {
required this.chatService,
});
/// TODO use "dartz" package because need Either<Failure, Result> for error handling
Future<ChatRoomModel> getChatRoom(String chatId) async {
try {
return (await chatService.getChatRoomModel(chatId))['chatRoom']!;
return (await chatService.getChatRoom(chatId))['chatRoom']!;
} catch (e) {
print(e);
throw (e);
rethrow;
}
}
Future<ChatMessagesModel> getChatMessages(String chatId) async {
try {
return (await chatService.getChatMessages(chatId));
} catch (e) {
print(e);
rethrow;
}
}
/// TODO use "dartz" package because need Either<Failure, Result> for error handling
Future<WebsocketInfoModel> getWebsocket() async {
try {
return (await chatService.getWebsocket());
} catch (e) {
print(e);
throw (e);
rethrow;
}
}
}