1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15: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

@ -1,4 +1,9 @@
import 'package:comunic/helpers/groups_helper.dart';
import 'package:comunic/helpers/notifications_helper.dart';
import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/groups_list.dart';
import 'package:comunic/lists/notifications_list.dart';
import 'package:comunic/lists/users_list.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart';
@ -16,6 +21,8 @@ class NotificationsScreen extends StatefulWidget {
class _NotificationsScreenState extends State<NotificationsScreen> {
NotificationsList _list;
UsersList _users;
GroupsList _groups;
_Status _status = _Status.LOADING;
void setStatus(_Status s) => setState(() => _status = s);
@ -23,6 +30,31 @@ class _NotificationsScreenState extends State<NotificationsScreen> {
Future<void> _loadList() async {
setStatus(_Status.LOADING);
try {
final list = await NotificationsHelper().getUnread();
final users = await UsersHelper().getListWithThrow(list.usersIds);
final groups = await GroupsHelper().getListOrThrow(list.groupsIds);
setState(() {
_list = list;
_users = users;
_groups = groups;
});
} on Exception catch (e) {
print("Exception while getting the list of notifications!");
print(e);
} on Error catch (e) {
print("Error while getting the list of notifications!");
print(e.stackTrace);
}
}
@override
void didChangeDependencies() {
super.didChangeDependencies();
_loadList();
}
@override