mirror of
https://github.com/Iconica-Development/flutter_chat.git
synced 2025-05-19 10:53:51 +02:00
fix: add check for groupchats with only 1 member
This commit is contained in:
parent
82448ab9e0
commit
c9a11758d8
2 changed files with 13 additions and 8 deletions
|
@ -7,6 +7,7 @@
|
||||||
- Change the ChatTranslations constructor to require all translations or use the ChatTranslations.empty constructor if you don't want to specify all translations
|
- Change the ChatTranslations constructor to require all translations or use the ChatTranslations.empty constructor if you don't want to specify all translations
|
||||||
- Remove the Divider between the users on the new chat screen
|
- Remove the Divider between the users on the new chat screen
|
||||||
- Add option to set a custom padding around the list of chats
|
- Add option to set a custom padding around the list of chats
|
||||||
|
- Fix nullpointer when firstWhere returns null because there is only 1 person in a groupchat
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
|
|
||||||
|
|
|
@ -91,11 +91,15 @@ class FirebaseChatOverviewService implements ChatOverviewService {
|
||||||
var chat = element.doc.data();
|
var chat = element.doc.data();
|
||||||
if (chat == null) return;
|
if (chat == null) return;
|
||||||
|
|
||||||
var otherUser = await _userService.getUser(
|
var otherUser = chat.users.any(
|
||||||
|
(element) => element != currentUser?.id,
|
||||||
|
)
|
||||||
|
? await _userService.getUser(
|
||||||
chat.users.firstWhere(
|
chat.users.firstWhere(
|
||||||
(element) => element != currentUser?.id,
|
(element) => element != currentUser?.id,
|
||||||
),
|
),
|
||||||
);
|
)
|
||||||
|
: null;
|
||||||
|
|
||||||
var unread =
|
var unread =
|
||||||
await _addUnreadChatSubscription(chat.id!, currentUser!.id!);
|
await _addUnreadChatSubscription(chat.id!, currentUser!.id!);
|
||||||
|
@ -144,10 +148,10 @@ class FirebaseChatOverviewService implements ChatOverviewService {
|
||||||
imageUrl: chat.imageUrl ?? '',
|
imageUrl: chat.imageUrl ?? '',
|
||||||
unreadMessages: unread,
|
unreadMessages: unread,
|
||||||
users: users,
|
users: users,
|
||||||
lastMessage: chat.lastMessage != null
|
lastMessage: chat.lastMessage != null && otherUser != null
|
||||||
? chat.lastMessage!.imageUrl == null
|
? chat.lastMessage!.imageUrl == null
|
||||||
? ChatTextMessageModel(
|
? ChatTextMessageModel(
|
||||||
sender: otherUser!,
|
sender: otherUser,
|
||||||
text: chat.lastMessage!.text!,
|
text: chat.lastMessage!.text!,
|
||||||
timestamp: DateTime.fromMillisecondsSinceEpoch(
|
timestamp: DateTime.fromMillisecondsSinceEpoch(
|
||||||
chat.lastMessage!.timestamp
|
chat.lastMessage!.timestamp
|
||||||
|
@ -155,7 +159,7 @@ class FirebaseChatOverviewService implements ChatOverviewService {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: ChatImageMessageModel(
|
: ChatImageMessageModel(
|
||||||
sender: otherUser!,
|
sender: otherUser,
|
||||||
imageUrl: chat.lastMessage!.imageUrl!,
|
imageUrl: chat.lastMessage!.imageUrl!,
|
||||||
timestamp: DateTime.fromMillisecondsSinceEpoch(
|
timestamp: DateTime.fromMillisecondsSinceEpoch(
|
||||||
chat.lastMessage!.timestamp
|
chat.lastMessage!.timestamp
|
||||||
|
|
Loading…
Reference in a new issue