1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Display the list of memberships

This commit is contained in:
2020-05-05 19:33:04 +02:00
parent 286639889b
commit c5c544fb34
5 changed files with 130 additions and 5 deletions

View File

@ -7,7 +7,6 @@ import 'package:comunic/models/group.dart';
/// @author Pierre HUBERT
class GroupsList extends MapBase<int, Group> {
final Map<int, Group> _groups = Map();
@override
@ -25,5 +24,5 @@ class GroupsList extends MapBase<int, Group> {
@override
Group remove(Object key) => _groups.remove(key);
Group getGroup(int id) => this[id];
}

View File

@ -5,4 +5,29 @@ import 'package:comunic/models/membership.dart';
///
/// @author Pierre Hubert
class MembershipList extends AbstractList<Membership> {}
class MembershipList extends AbstractList<Membership> {
/// Get the IDs of all the users included in some way in this list
Set<int> get usersId {
final s = Set<int>();
forEach((m) {
switch (m.type) {
case MembershipType.FRIEND:
s.add(m.friend.id);
break;
case MembershipType.GROUP:
break;
case MembershipType.CONVERSATION:
s.addAll(m.conversation.members);
break;
}
});
return s;
}
/// Get the ID of the groups included in this list
Set<int> get groupsId => where((f) => f.type == MembershipType.GROUP)
.map((f) => f.groupID)
.toSet();
}