mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Get information about users & groups related to the notifications
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user