forked from eatvio/eatvio_app
feat(chat): add init and dispose chat, typing info, receive a messages
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user