forked from eatvio/eatvio_app
59 lines
1.3 KiB
Dart
59 lines
1.3 KiB
Dart
import 'dart:io';
|
|
|
|
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';
|
|
|
|
class ChatRepository {
|
|
final ChatService chatService;
|
|
|
|
ChatRepository({
|
|
required this.chatService,
|
|
});
|
|
|
|
Future<void> sendMessage({
|
|
required String chatId,
|
|
String? data,
|
|
List<File>? filesList,
|
|
}) async {
|
|
try {
|
|
await chatService.sendMessage(
|
|
id: chatId,
|
|
data: data,
|
|
filesList: filesList,
|
|
);
|
|
} catch (e) {
|
|
print(e);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ChatRoomModel> getChatRoom(String chatId) async {
|
|
try {
|
|
return (await chatService.getChatRoom(id: chatId))['chatRoom']!;
|
|
} catch (e) {
|
|
print(e);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<ChatMessagesModel> getChatMessages(String chatId, int page) async {
|
|
try {
|
|
return (await chatService.getChatMessages(id: chatId, page: page));
|
|
} catch (e) {
|
|
print(e);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
Future<WebsocketInfoModel> getWebsocket() async {
|
|
try {
|
|
return (await chatService.getWebsocket());
|
|
} catch (e) {
|
|
print(e);
|
|
rethrow;
|
|
}
|
|
}
|
|
}
|