mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 04:04:18 +00:00 
			
		
		
		
	Diplay the number of unread notifications / conversations
This commit is contained in:
		@@ -1,5 +1,6 @@
 | 
			
		||||
import 'package:comunic/lists/notifications_list.dart';
 | 
			
		||||
import 'package:comunic/models/api_request.dart';
 | 
			
		||||
import 'package:comunic/models/count_unread_notifications.dart';
 | 
			
		||||
import 'package:comunic/models/notification.dart';
 | 
			
		||||
 | 
			
		||||
/// Notifications helper
 | 
			
		||||
@@ -47,6 +48,22 @@ const _NotificationsTypeAPImapping = {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class NotificationsHelper {
 | 
			
		||||
  /// Get the number of unread notifications
 | 
			
		||||
  ///
 | 
			
		||||
  /// This method throws in case of error
 | 
			
		||||
  Future<CountUnreadNotifications> countUnread() async {
 | 
			
		||||
    final response =
 | 
			
		||||
        await APIRequest(uri: "notifications/count_all_news", needLogin: true)
 | 
			
		||||
            .exec();
 | 
			
		||||
 | 
			
		||||
    final content = response.assertOk().getObject();
 | 
			
		||||
 | 
			
		||||
    return CountUnreadNotifications(
 | 
			
		||||
      notifications: content["notifications"],
 | 
			
		||||
      conversations: content["conversations"],
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Get the list of unread notifications of the user
 | 
			
		||||
  Future<NotificationsList> getUnread() async {
 | 
			
		||||
    final response =
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user