mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-25 06:19:22 +00:00
Fix unread conversations dropdown
This commit is contained in:
parent
88217202f8
commit
de7feb36ce
@ -9,7 +9,19 @@ class UnreadConversationsList extends AbstractList<UnreadConversation> {
|
|||||||
/// Get the ID of the users included in this list
|
/// Get the ID of the users included in this list
|
||||||
Set<int> get usersID {
|
Set<int> get usersID {
|
||||||
final set = Set<int>();
|
final set = Set<int>();
|
||||||
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<int> get groupsID {
|
||||||
|
final set = Set<int>();
|
||||||
|
forEach((element) {
|
||||||
|
if (element.conv.isGroupConversation) set.add(element.conv.groupID);
|
||||||
|
});
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'package:comunic/helpers/conversations_helper.dart';
|
import 'package:comunic/helpers/conversations_helper.dart';
|
||||||
import 'package:comunic/helpers/events_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/helpers/users_helper.dart';
|
||||||
|
import 'package:comunic/lists/groups_list.dart';
|
||||||
import 'package:comunic/lists/unread_conversations_list.dart';
|
import 'package:comunic/lists/unread_conversations_list.dart';
|
||||||
import 'package:comunic/lists/users_list.dart';
|
import 'package:comunic/lists/users_list.dart';
|
||||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
import 'package:comunic/ui/routes/main_route/main_route.dart';
|
||||||
@ -25,12 +27,14 @@ class _UnreadConversationsScreenState
|
|||||||
extends SafeState<UnreadConversationsScreen> {
|
extends SafeState<UnreadConversationsScreen> {
|
||||||
UnreadConversationsList _list;
|
UnreadConversationsList _list;
|
||||||
UsersList _users;
|
UsersList _users;
|
||||||
|
GroupsList _groups;
|
||||||
|
|
||||||
final _key = GlobalKey<AsyncScreenWidgetState>();
|
final _key = GlobalKey<AsyncScreenWidgetState>();
|
||||||
|
|
||||||
Future<void> _refresh() async {
|
Future<void> _refresh() async {
|
||||||
_list = await ConversationsHelper.getListUnread();
|
_list = await ConversationsHelper.getListUnread();
|
||||||
_users = await UsersHelper().getListWithThrow(_list.usersID);
|
_users = await UsersHelper().getListWithThrow(_list.usersID);
|
||||||
|
_groups = await GroupsHelper().getList(_list.groupsID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -93,6 +97,9 @@ class _UnreadConversationsScreenState
|
|||||||
leading: ConversationImageWidget(
|
leading: ConversationImageWidget(
|
||||||
conversation: conv.conv,
|
conversation: conv.conv,
|
||||||
users: _users,
|
users: _users,
|
||||||
|
group: conv.conv.isGroupConversation
|
||||||
|
? _groups.getGroup(conv.conv.groupID)
|
||||||
|
: null,
|
||||||
),
|
),
|
||||||
title: Text(ConversationsHelper.getConversationName(conv.conv, _users)),
|
title: Text(ConversationsHelper.getConversationName(conv.conv, _users)),
|
||||||
subtitle: RichText(
|
subtitle: RichText(
|
||||||
@ -104,7 +111,8 @@ class _UnreadConversationsScreenState
|
|||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
trailing: Text(diffTimeFromNowToStr(conv.message.timeSent)),
|
trailing: Text(diffTimeFromNowToStr(conv.message.timeSent)),
|
||||||
onTap: () => MainController.of(context).openConversationById(conv.conv.id),
|
onTap: () =>
|
||||||
|
MainController.of(context).openConversationById(conv.conv.id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user