From de7feb36ce8226ef34f540aa2e0086530cfbc472 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 25 Apr 2021 16:12:36 +0200 Subject: [PATCH] Fix unread conversations dropdown --- lib/lists/unread_conversations_list.dart | 14 +++++++++++++- lib/ui/screens/unread_conversations_screen.dart | 10 +++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/lists/unread_conversations_list.dart b/lib/lists/unread_conversations_list.dart index 55f18da..ae8d568 100644 --- a/lib/lists/unread_conversations_list.dart +++ b/lib/lists/unread_conversations_list.dart @@ -9,7 +9,19 @@ class UnreadConversationsList extends AbstractList { /// Get the ID of the users included in this list Set get usersID { final set = Set(); - forEach((element) => set.addAll(element.message.usersID)); + forEach((element) { + set.addAll(element.conv.membersID); + set.addAll(element.message.usersID); + }); + return set; + } + + /// Get the ID of the groups references ind this list + Set get groupsID { + final set = Set(); + forEach((element) { + if (element.conv.isGroupConversation) set.add(element.conv.groupID); + }); return set; } } diff --git a/lib/ui/screens/unread_conversations_screen.dart b/lib/ui/screens/unread_conversations_screen.dart index 2606e93..2e896c0 100644 --- a/lib/ui/screens/unread_conversations_screen.dart +++ b/lib/ui/screens/unread_conversations_screen.dart @@ -1,6 +1,8 @@ import 'package:comunic/helpers/conversations_helper.dart'; import 'package:comunic/helpers/events_helper.dart'; +import 'package:comunic/helpers/groups_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; +import 'package:comunic/lists/groups_list.dart'; import 'package:comunic/lists/unread_conversations_list.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/ui/routes/main_route/main_route.dart'; @@ -25,12 +27,14 @@ class _UnreadConversationsScreenState extends SafeState { UnreadConversationsList _list; UsersList _users; + GroupsList _groups; final _key = GlobalKey(); Future _refresh() async { _list = await ConversationsHelper.getListUnread(); _users = await UsersHelper().getListWithThrow(_list.usersID); + _groups = await GroupsHelper().getList(_list.groupsID); } @override @@ -93,6 +97,9 @@ class _UnreadConversationsScreenState leading: ConversationImageWidget( conversation: conv.conv, users: _users, + group: conv.conv.isGroupConversation + ? _groups.getGroup(conv.conv.groupID) + : null, ), title: Text(ConversationsHelper.getConversationName(conv.conv, _users)), subtitle: RichText( @@ -104,7 +111,8 @@ class _UnreadConversationsScreenState ]), ), trailing: Text(diffTimeFromNowToStr(conv.message.timeSent)), - onTap: () => MainController.of(context).openConversationById(conv.conv.id), + onTap: () => + MainController.of(context).openConversationById(conv.conv.id), ); } }