2020-04-20 12:02:32 +00:00
|
|
|
import 'package:comunic/lists/abstract_list.dart';
|
|
|
|
import 'package:comunic/models/call_member.dart';
|
|
|
|
|
|
|
|
/// Call members list
|
|
|
|
///
|
|
|
|
/// @author Pierre Hubert
|
|
|
|
|
2020-04-20 12:13:03 +00:00
|
|
|
class CallMembersList extends AbstractList<CallMember> {
|
|
|
|
/// Get the IDs of the users in this list
|
2020-04-20 13:02:49 +00:00
|
|
|
Set<int> get usersID => this.map((f) => f.userID).toSet();
|
2020-04-20 12:13:03 +00:00
|
|
|
|
|
|
|
/// Remove a specific member from this list
|
2020-04-20 13:02:49 +00:00
|
|
|
void removeUser(int userID) => this.removeWhere((f) => f.userID == userID);
|
2020-04-20 12:58:23 +00:00
|
|
|
|
|
|
|
/// Get the connection of a specific user
|
2020-04-20 13:02:49 +00:00
|
|
|
CallMember getUser(int userID) => this.firstWhere((f) => f.userID == userID);
|
2020-04-20 13:50:01 +00:00
|
|
|
|
|
|
|
/// Extract ready peers from this list
|
|
|
|
CallMembersList get readyPeers =>
|
|
|
|
CallMembersList()..addAll(where((f) => f.status == MemberStatus.READY));
|
2020-04-20 12:13:03 +00:00
|
|
|
}
|