mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
50 lines
968 B
Dart
50 lines
968 B
Dart
import 'dart:collection';
|
|
|
|
import 'package:comunic/models/post.dart';
|
|
|
|
/// Posts List
|
|
///
|
|
/// Contains method to easily process a list of posts
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
class PostsList extends ListBase<Post> {
|
|
List<Post> _list = List();
|
|
|
|
int get length => _list.length;
|
|
|
|
set length(int l) => _list.length = l;
|
|
|
|
@override
|
|
Post operator [](int index) => _list[index];
|
|
|
|
@override
|
|
void operator []=(int index, Post value) => _list[index] = value;
|
|
|
|
// Get the list of users ID in this set
|
|
Set<int> get usersID {
|
|
Set<int> set = Set();
|
|
|
|
forEach((p) {
|
|
set.add(p.userID);
|
|
|
|
if (p.userPageID != null && p.userPageID > 0) set.add(p.userPageID);
|
|
|
|
if (p.comments != null) set.addAll(p.comments.usersID);
|
|
});
|
|
|
|
return set;
|
|
}
|
|
|
|
/// Get the list of groups in this list of posts
|
|
Set<int> get groupsID {
|
|
Set<int> set = Set();
|
|
|
|
forEach((p) {
|
|
if (p.isGroupPost) set.add(p.groupID);
|
|
});
|
|
|
|
return set;
|
|
}
|
|
}
|