1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-10-23 06:53:23 +00:00
comunicmobile/lib/lists/notifications_list.dart

50 lines
1.5 KiB
Dart
Raw Normal View History

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
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;
}
}