Fixed notification pagination for all and unread
This commit is contained in:
@@ -13,7 +13,7 @@ class NotificationAllTab extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
final notifications =
|
||||
viewModel.notificationResponse?.data?.notifications ?? [];
|
||||
viewModel.allNotificationResponse?.data?.notifications ?? [];
|
||||
|
||||
return ListView.builder(
|
||||
controller: scrollController,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/view_models/notification_view_model.dart';
|
||||
|
||||
import 'package:tm_app/views/notification/strings/notification_strings.dart';
|
||||
import 'notification_card.dart';
|
||||
|
||||
class NotificationImportantTab extends StatelessWidget {
|
||||
@@ -12,13 +12,25 @@ class NotificationImportantTab extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
final allNotifications =
|
||||
viewModel.notificationResponse?.data?.notifications ?? [];
|
||||
|
||||
final importantNotifications = allNotifications
|
||||
.where((n) => n.priority?.toLowerCase() == 'important')
|
||||
if (viewModel.isLoadingImportant) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final importantFromApi = viewModel.importantNotificationResponse?.data?.notifications ?? [];
|
||||
|
||||
final allNotifications = viewModel.allNotificationResponse?.data?.notifications ?? [];
|
||||
|
||||
final source = importantFromApi.isNotEmpty ? importantFromApi : allNotifications;
|
||||
|
||||
final importantNotifications = source
|
||||
.where((n) => (n.priority ?? '').toLowerCase() == 'important')
|
||||
.toList();
|
||||
|
||||
if (importantNotifications.isEmpty) {
|
||||
return const Center(child: Text(NotificationStrings.noImportantNotifications));
|
||||
}
|
||||
|
||||
return ListView.builder(
|
||||
controller: scrollController,
|
||||
itemCount: importantNotifications.length,
|
||||
|
||||
@@ -14,7 +14,7 @@ class NotificationUnreadTab extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final viewModel = context.watch<NotificationViewModel>();
|
||||
|
||||
if (viewModel.isUnreadLoading) {
|
||||
if (viewModel.isLoadingUnread){
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user