1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 00:05:16 +00:00

Diplay the number of unread notifications / conversations

This commit is contained in:
2020-04-17 13:28:01 +02:00
parent 90d58bbee3
commit 003eb1efc2
3 changed files with 115 additions and 14 deletions

View File

@ -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 =