Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/chat_repository_interface/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() =>
Expand All @@ -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));
});
}
}
4 changes: 2 additions & 2 deletions packages/firebase_chat_repository/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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: (_, __) => [
Expand Down
22 changes: 10 additions & 12 deletions packages/flutter_chat/lib/src/screens/chat_profile_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
13 changes: 10 additions & 3 deletions packages/flutter_chat/lib/src/screens/chat_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -58,7 +58,7 @@ class ChatScreen extends HookWidget {
return options.builders.baseScreenBuilder!.call(
context,
mapScreenType,
const _AppBar(),
_AppBar(onExit),
translations.chatsTitle,
_Body(
onPressChat: onPressChat,
Expand All @@ -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) {
Expand All @@ -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,
),
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter_chat/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand Down