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
|
|
|
|
List<int> get usersIds {
|
|
|
|
final list = List<int>();
|
|
|
|
|
|
|
|
forEach((n) {
|
|
|
|
if (!list.contains(n.fromUser)) list.add(n.fromUser);
|
|
|
|
|
|
|
|
if (n.onElemType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
|
|
|
n.onElemType == NotificationElementType.USER_PAGE) {
|
|
|
|
if (!list.contains(n.onElemId)) list.add(n.onElemId);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n.fromContainerType == NotificationElementType.FRIENDSHIP_REQUEST ||
|
|
|
|
n.fromContainerType == NotificationElementType.USER_PAGE) {
|
|
|
|
if (!list.contains(n.fromContainerId)) list.add(n.fromContainerId);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the ID of all the groups related to the notifications
|
|
|
|
/// included in the list
|
|
|
|
List<int> get groupsIds {
|
|
|
|
final list = List<int>();
|
|
|
|
|
|
|
|
forEach((n) {
|
|
|
|
if (n.onElemType == NotificationElementType.GROUP_PAGE &&
|
|
|
|
!list.contains(n.onElemId)) list.add(n.onElemId);
|
|
|
|
|
|
|
|
if (n.fromContainerType == NotificationElementType.GROUP_PAGE &&
|
|
|
|
!list.contains(n.fromContainerId)) list.add(n.fromContainerId);
|
|
|
|
|
|
|
|
if (n.onElemType == NotificationElementType.GROUP_MEMBERSHIP &&
|
|
|
|
!list.contains(n.onElemId)) list.add(n.onElemId);
|
|
|
|
});
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
}
|