1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Get information about users & groups related to the notifications

This commit is contained in:
2019-11-01 15:37:27 +01:00
parent f0fdb3b378
commit 0b204afff9
3 changed files with 58 additions and 17 deletions

View File

@ -8,21 +8,19 @@ import 'package:comunic/models/notification.dart';
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>();
Set<int> get usersIds {
final list = Set<int>();
forEach((n) {
if (!list.contains(n.fromUser)) list.add(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);
}
n.onElemType == NotificationElementType.USER_PAGE)
list.add(n.onElemId);
if (n.fromContainerType == NotificationElementType.FRIENDSHIP_REQUEST ||
n.fromContainerType == NotificationElementType.USER_PAGE) {
if (!list.contains(n.fromContainerId)) list.add(n.fromContainerId);
}
n.fromContainerType == NotificationElementType.USER_PAGE)
list.add(n.fromContainerId);
});
return list;
@ -30,18 +28,18 @@ class NotificationsList extends AbstractList<Notification> {
/// Get the ID of all the groups related to the notifications
/// included in the list
List<int> get groupsIds {
final list = List<int>();
Set<int> get groupsIds {
final list = Set<int>();
forEach((n) {
if (n.onElemType == NotificationElementType.GROUP_PAGE &&
!list.contains(n.onElemId)) list.add(n.onElemId);
if (n.onElemType == NotificationElementType.GROUP_PAGE)
list.add(n.onElemId);
if (n.fromContainerType == NotificationElementType.GROUP_PAGE &&
!list.contains(n.fromContainerId)) list.add(n.fromContainerId);
if (n.fromContainerType == NotificationElementType.GROUP_PAGE)
list.add(n.fromContainerId);
if (n.onElemType == NotificationElementType.GROUP_MEMBERSHIP &&
!list.contains(n.onElemId)) list.add(n.onElemId);
if (n.onElemType == NotificationElementType.GROUP_MEMBERSHIP)
list.add(n.onElemId);
});
return list;