mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Create new methods in NotificationsList object
This commit is contained in:
parent
61124c34ef
commit
f0fdb3b378
@ -5,4 +5,45 @@ import 'package:comunic/models/notification.dart';
|
|||||||
///
|
///
|
||||||
/// @author Pierre HUBERT
|
/// @author Pierre HUBERT
|
||||||
|
|
||||||
class NotificationsList extends AbstractList<Notification> {}
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user