This commit is contained in:
Jacques Doeleman 2025-04-24 11:39:14 +00:00 committed by GitHub
commit 7cde32e2cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 52 additions and 36 deletions

View file

@ -1,3 +1,8 @@
## 6.0.1
- Added proper implementation for getAllUsersForChat in Firebase repository
- Removed cast which throws an error in ChatProfileScreen
- Added BackButton to ChatOverviewScreen when onExit is not null
## 6.0.0
- Added pending message repository to temporarily store messages that are not yet received by the backend
- Added pending message icons next to time on default messages

View file

@ -1,6 +1,6 @@
name: chat_repository_interface
description: "The interface for a chat repository"
version: 6.0.0
version: 6.0.1
homepage: "https://github.com/Iconica-Development"
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/

View file

@ -7,10 +7,13 @@ class FirebaseUserRepository implements UserRepositoryInterface {
FirebaseUserRepository({
FirebaseFirestore? firestore,
String userCollection = "users",
String chatCollection = "chats",
}) : _userCollection = userCollection,
_chatCollection = chatCollection,
_firestore = firestore ?? FirebaseFirestore.instance;
final FirebaseFirestore _firestore;
final String _userCollection;
final String _chatCollection;
@override
Stream<List<UserModel>> getAllUsers() =>
@ -35,19 +38,20 @@ class FirebaseUserRepository implements UserRepositoryInterface {
);
@override
Stream<List<UserModel>> getAllUsersForChat({required String chatId}) =>
_firestore
.collection(_userCollection)
.where("chats", arrayContains: chatId)
.snapshots()
.map(
(querySnapshot) => querySnapshot.docs
.map(
(doc) => UserModel.fromMap(
doc.id,
doc.data(),
),
)
.toList(),
);
Stream<List<UserModel>> getAllUsersForChat({required String chatId}) {
var chatDocStream =
_firestore.collection(_chatCollection).doc(chatId).snapshots();
return chatDocStream.asyncMap((snapshot) async {
if (!snapshot.exists) return [];
var chatModel = ChatModel.fromMap(snapshot.id, snapshot.data()!);
var userIds = chatModel.users;
var userStreams =
userIds.map((userId) => getUser(userId: userId)).toList();
return Future.wait(userStreams.map((s) => s.first));
});
}
}

View file

@ -1,6 +1,6 @@
name: firebase_chat_repository
description: "Firebase repository implementation for the chat domain repository interface"
version: 6.0.0
version: 6.0.1
homepage: "https://github.com/Iconica-Development"
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
@ -15,7 +15,7 @@ dependencies:
chat_repository_interface:
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^6.0.0
version: ^6.0.1
firebase_storage: any
cloud_firestore: any

View file

@ -78,6 +78,8 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
final ChatOptions options;
/// Callback for when the user wants to navigate back.
///
/// This will also show the back button in the appbar when not null
final VoidCallback? onExit;
/// Implemented by subclasses to provide the initial route of the userstory.
@ -108,7 +110,7 @@ abstract class _BaseChatNavigatorUserstory extends HookWidget {
service: service,
popHandler: popHandler,
child: NavigatorPopHandler(
onPop: () => popHandler.handlePop(),
onPop: popHandler.handlePop,
child: Navigator(
key: nestedNavigatorKey,
onGenerateInitialRoutes: (_, __) => [

View file

@ -193,18 +193,16 @@ class _Body extends StatelessWidget {
);
var targetUser = user ??
(
chat != null
? UserModel(
id: UniqueKey().toString(),
firstName: chat?.chatName,
imageUrl: chat?.imageUrl,
)
: UserModel(
id: UniqueKey().toString(),
firstName: options.translations.groupNameEmpty,
),
) as UserModel;
(chat != null
? UserModel(
id: UniqueKey().toString(),
firstName: chat?.chatName,
imageUrl: chat?.imageUrl,
)
: UserModel(
id: UniqueKey().toString(),
firstName: options.translations.groupNameEmpty,
));
return Stack(
children: [

View file

@ -46,7 +46,7 @@ class ChatScreen extends HookWidget {
if (options.builders.baseScreenBuilder == null) {
return Scaffold(
appBar: const _AppBar(),
appBar: _AppBar(onExit),
body: _Body(
onPressChat: onPressChat,
onPressStartChat: onPressStartChat,
@ -58,7 +58,7 @@ class ChatScreen extends HookWidget {
return options.builders.baseScreenBuilder!.call(
context,
mapScreenType,
const _AppBar(),
_AppBar(onExit),
translations.chatsTitle,
_Body(
onPressChat: onPressChat,
@ -70,7 +70,9 @@ class ChatScreen extends HookWidget {
}
class _AppBar extends StatelessWidget implements PreferredSizeWidget {
const _AppBar();
const _AppBar(this.onExit);
final VoidCallback? onExit;
@override
Widget build(BuildContext context) {
@ -81,6 +83,11 @@ class _AppBar extends StatelessWidget implements PreferredSizeWidget {
var theme = Theme.of(context);
return AppBar(
leading: onExit != null
? BackButton(
onPressed: () => onExit?.call(),
)
: null,
title: Text(
translations.chatsTitle,
),

View file

@ -1,6 +1,6 @@
name: flutter_chat
description: "User story of the chat domain for quick integration into flutter apps"
version: 6.0.0
version: 6.0.1
publish_to: https://forgejo.internal.iconica.nl/api/packages/internal/pub/
environment:
@ -26,7 +26,7 @@ dependencies:
version: ^1.6.0
chat_repository_interface:
hosted: https://forgejo.internal.iconica.nl/api/packages/internal/pub
version: ^6.0.0
version: ^6.0.1
dev_dependencies:
flutter_test: