feat: add senderId and chatId to uploadImage

This commit is contained in:
Freek van de Ven 2025-02-17 16:41:02 +01:00 committed by FlutterJoey
parent e7bb4909ba
commit 23f61dd5ff
6 changed files with 15 additions and 0 deletions

View file

@ -15,6 +15,7 @@
- Added chatTitleResolver that can be used to resolve the chat title from the chat model or return null to allow for default behavior
- Added ChatPaginationControls to the ChatOptions to allow for more control over the pagination
- Fixed that chat message is automatically sent when the user presses enter on the keyboard in the chat input
- Added sender and chatId to uploadImage in the ChatRepositoryInterface
## 4.0.0
- Move to the new user story architecture

View file

@ -105,9 +105,13 @@ abstract class ChatRepositoryInterface {
/// Upload an image with the given parameters.
/// [path] is the path of the image.
/// [image] is the image data.
/// [senderId] is the sender id.
/// [chatId] is the chat id.
/// Returns the image url.
Future<String> uploadImage({
required String path,
required String senderId,
required String chatId,
required Uint8List image,
});
}

View file

@ -268,6 +268,8 @@ class LocalChatRepository implements ChatRepositoryInterface {
Future<String> uploadImage({
required String path,
required Uint8List image,
required String chatId,
required String senderId,
}) =>
Future.value("https://picsum.photos/200/300");

View file

@ -211,14 +211,18 @@ class ChatService {
/// Upload an image with the given parameters.
/// [path] is the image path.
/// [image] is the image bytes.
/// [chatId] is the chat id.
/// Returns a [Future] of [String].
Future<String> uploadImage({
required String path,
required Uint8List image,
required String chatId,
}) =>
chatRepository.uploadImage(
path: path,
image: image,
senderId: userId,
chatId: chatId,
);
/// Mark the chat as read with the given parameters.

View file

@ -190,6 +190,8 @@ class FirebaseChatRepository implements ChatRepositoryInterface {
Future<String> uploadImage({
required String path,
required Uint8List image,
required String chatId,
required String senderId,
}) async {
var ref = _storage.ref().child(_mediaPath).child(path);
var uploadTask = ref.putData(image);

View file

@ -54,6 +54,7 @@ MaterialPageRoute chatDetailRoute({
var path = await chatService.uploadImage(
path: "chats/$chatId-$userId-${DateTime.now()}",
image: data,
chatId: chatId,
);
await chatService.sendMessage(
messageId: "$chatId-$userId-${DateTime.now()}",
@ -213,6 +214,7 @@ MaterialPageRoute _newGroupChatOverviewRoute({
path = await chatService.uploadImage(
path: "groups/$title",
image: image,
chatId: "",
);
}
var chat = await _createGroupChat(