mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-30 00:36:28 +00:00
48 lines
1.3 KiB
Dart
48 lines
1.3 KiB
Dart
import 'package:comunic/lists/abstract_list.dart';
|
|
import 'package:comunic/models/notification.dart';
|
|
|
|
/// Notifications list
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
class NotificationsList extends AbstractList<Notification> {
|
|
/// Get the ID of all the users related to the notifications
|
|
/// included in the list
|
|
Set<int> get usersIds {
|
|
final list = Set<int>();
|
|
|
|
forEach((n) {
|
|
list.add(n.fromUser);
|
|
|
|
if (n.onElemType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
|
n.onElemType == NotificationElementType.USER_PAGE)
|
|
list.add(n.onElemId);
|
|
|
|
if (n.fromContainerType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
|
n.fromContainerType == NotificationElementType.USER_PAGE)
|
|
list.add(n.fromContainerId);
|
|
});
|
|
|
|
return list;
|
|
}
|
|
|
|
/// Get the ID of all the groups related to the notifications
|
|
/// included in the list
|
|
Set<int> get groupsIds {
|
|
final list = Set<int>();
|
|
|
|
forEach((n) {
|
|
if (n.onElemType == NotificationElementType.GROUP_PAGE)
|
|
list.add(n.onElemId);
|
|
|
|
if (n.fromContainerType == NotificationElementType.GROUP_PAGE)
|
|
list.add(n.fromContainerId);
|
|
|
|
if (n.onElemType == NotificationElementType.GROUP_MEMBERSHIP)
|
|
list.add(n.onElemId);
|
|
});
|
|
|
|
return list;
|
|
}
|
|
}
|