mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Automatically refresh the list of notifications when required
This commit is contained in:
parent
1b13a90615
commit
0700014b3a
@ -1,3 +1,4 @@
|
||||
import 'package:comunic/helpers/events_helper.dart';
|
||||
import 'package:comunic/helpers/groups_helper.dart';
|
||||
import 'package:comunic/helpers/notifications_helper.dart';
|
||||
import 'package:comunic/helpers/users_helper.dart';
|
||||
@ -7,6 +8,7 @@ import 'package:comunic/lists/users_list.dart';
|
||||
import 'package:comunic/models/notification.dart' as n;
|
||||
import 'package:comunic/ui/routes/main_route.dart';
|
||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||
import 'package:comunic/ui/widgets/safe_state.dart';
|
||||
import 'package:comunic/utils/date_utils.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/navigation_utils.dart';
|
||||
@ -26,7 +28,7 @@ class NotificationsScreen extends StatefulWidget {
|
||||
_NotificationsScreenState createState() => _NotificationsScreenState();
|
||||
}
|
||||
|
||||
class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
class _NotificationsScreenState extends SafeState<NotificationsScreen> {
|
||||
NotificationsList _list;
|
||||
UsersList _users;
|
||||
GroupsList _groups;
|
||||
@ -62,6 +64,14 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
this.listenChangeState<NewNumberNotifsEvent>(
|
||||
(d) => _refreshKey.currentState.show());
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
@ -111,11 +121,11 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
|
||||
return ListView(
|
||||
children: _list
|
||||
.map((f) => _NotificationTile(
|
||||
notification: f,
|
||||
usersList: _users,
|
||||
groupsList: _groups,
|
||||
onDelete: _deleteNotification,
|
||||
))
|
||||
notification: f,
|
||||
usersList: _users,
|
||||
groupsList: _groups,
|
||||
onDelete: _deleteNotification,
|
||||
))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
@ -193,12 +203,12 @@ class _NotificationTile extends StatelessWidget {
|
||||
String message = "${srcUser.fullName} ";
|
||||
|
||||
switch (notification.type) {
|
||||
// Comment
|
||||
// Comment
|
||||
case n.NotificationType.COMMENT_CREATED:
|
||||
message += tr("posted a comment");
|
||||
break;
|
||||
|
||||
// Friendship requests
|
||||
// Friendship requests
|
||||
case n.NotificationType.SENT_FRIEND_REQUEST:
|
||||
message += tr("sent you a friendship request.");
|
||||
break;
|
||||
@ -211,7 +221,7 @@ class _NotificationTile extends StatelessWidget {
|
||||
message += tr("rejected your friendship request.");
|
||||
break;
|
||||
|
||||
// Groups membership
|
||||
// Groups membership
|
||||
case n.NotificationType.SENT_GROUP_MEMBERSHIP_INVITATION:
|
||||
message += tr("invited you to join the group");
|
||||
break;
|
||||
@ -236,14 +246,14 @@ class _NotificationTile extends StatelessWidget {
|
||||
message += tr("rejected your request to join the group");
|
||||
break;
|
||||
|
||||
// Generic element creation
|
||||
// Generic element creation
|
||||
case n.NotificationType.ELEM_CREATED:
|
||||
if (notification.onElemType == n.NotificationElementType.POST)
|
||||
message += tr("created a new post");
|
||||
break;
|
||||
|
||||
case n.NotificationType.ELEM_UPDATED:
|
||||
// Operation not implemented
|
||||
// Operation not implemented
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user