diff --git a/lib/lists/notifications_list.dart b/lib/lists/notifications_list.dart index f0d4ff1..f0ef100 100644 --- a/lib/lists/notifications_list.dart +++ b/lib/lists/notifications_list.dart @@ -5,4 +5,45 @@ import 'package:comunic/models/notification.dart'; /// /// @author Pierre HUBERT -class NotificationsList extends AbstractList {} +class NotificationsList extends AbstractList { + /// Get the ID of all the users related to the notifications + /// included in the list + List get usersIds { + final list = List(); + + 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 get groupsIds { + final list = List(); + + 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; + } +}