2019-04-23 15:29:58 +00:00
|
|
|
import 'dart:collection';
|
|
|
|
|
|
|
|
import 'package:comunic/models/conversation.dart';
|
|
|
|
|
|
|
|
/// Conversations list
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
class ConversationsList extends ListBase<Conversation> {
|
2021-03-13 14:14:54 +00:00
|
|
|
final List<Conversation> _list = [];
|
2019-04-23 15:29:58 +00:00
|
|
|
|
|
|
|
set length(l) => _list.length = l;
|
2021-03-10 16:54:41 +00:00
|
|
|
|
2019-04-23 15:29:58 +00:00
|
|
|
int get length => _list.length;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Conversation operator [](int index) => _list[index];
|
|
|
|
|
|
|
|
@override
|
|
|
|
void operator []=(int index, Conversation value) => _list[index] = value;
|
|
|
|
|
|
|
|
/// Get the entire lists of users ID in this list
|
2021-03-10 16:54:41 +00:00
|
|
|
Set<int> get allUsersID {
|
|
|
|
final Set<int> list = Set();
|
|
|
|
forEach((c) => c.members.forEach((member) => list.add(member.userID)));
|
2019-04-23 15:29:58 +00:00
|
|
|
return list;
|
|
|
|
}
|
2021-04-06 16:04:16 +00:00
|
|
|
|
|
|
|
/// Get the entire lists of groups ID in this list
|
|
|
|
Set<int> get allGroupsID => where((element) => element.isGroupConversation)
|
|
|
|
.map((e) => e.groupID)
|
|
|
|
.toSet();
|
2019-04-23 15:29:58 +00:00
|
|
|
}
|