2019-11-01 13:55:28 +00:00
|
|
|
import 'package:comunic/lists/abstract_list.dart';
|
|
|
|
import 'package:comunic/models/notification.dart';
|
|
|
|
|
|
|
|
/// Notifications list
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
2019-11-01 14:31:44 +00:00
|
|
|
class NotificationsList extends AbstractList<Notification> {
|
|
|
|
/// Get the ID of all the users related to the notifications
|
|
|
|
/// included in the list
|
2022-03-10 18:39:57 +00:00
|
|
|
Set<int?> get usersIds {
|
|
|
|
final list = Set<int?>();
|
2019-11-01 14:31:44 +00:00
|
|
|
|
|
|
|
forEach((n) {
|
2019-11-01 14:37:27 +00:00
|
|
|
list.add(n.fromUser);
|
2019-11-01 14:31:44 +00:00
|
|
|
|
|
|
|
if (n.onElemType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
2019-11-01 14:37:27 +00:00
|
|
|
n.onElemType == NotificationElementType.USER_PAGE)
|
|
|
|
list.add(n.onElemId);
|
2019-11-01 14:31:44 +00:00
|
|
|
|
|
|
|
if (n.fromContainerType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
2019-11-01 14:37:27 +00:00
|
|
|
n.fromContainerType == NotificationElementType.USER_PAGE)
|
|
|
|
list.add(n.fromContainerId);
|
2019-11-01 14:31:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the ID of all the groups related to the notifications
|
|
|
|
/// included in the list
|
2022-03-10 18:39:57 +00:00
|
|
|
Set<int?> get groupsIds {
|
|
|
|
final list = Set<int?>();
|
2019-11-01 14:31:44 +00:00
|
|
|
|
|
|
|
forEach((n) {
|
2019-11-01 14:37:27 +00:00
|
|
|
if (n.onElemType == NotificationElementType.GROUP_PAGE)
|
|
|
|
list.add(n.onElemId);
|
2019-11-01 14:31:44 +00:00
|
|
|
|
2019-11-01 14:37:27 +00:00
|
|
|
if (n.fromContainerType == NotificationElementType.GROUP_PAGE)
|
|
|
|
list.add(n.fromContainerId);
|
2019-11-01 14:31:44 +00:00
|
|
|
|
2019-11-01 14:37:27 +00:00
|
|
|
if (n.onElemType == NotificationElementType.GROUP_MEMBERSHIP)
|
|
|
|
list.add(n.onElemId);
|
2019-11-01 14:31:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|