Skip to content

Commit 215def2

Browse files
committed
feat(account): add pagination limit constant and update fetch logic
- Introduce _notificationsFetchLimit constant for notification pagination - Update pagination limit from 20 to _notificationsFetchLimit in both initial fetch and load more operations - Improve code maintainability and readability by using a constant for pagination limit
1 parent 3887218 commit 215def2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/account/bloc/in_app_notification_center_bloc.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ part 'in_app_notification_center_state.dart';
2222
/// {@endtemplate}
2323
class InAppNotificationCenterBloc
2424
extends Bloc<InAppNotificationCenterEvent, InAppNotificationCenterState> {
25+
/// The number of notifications to fetch per page.
26+
static const _notificationsFetchLimit = 10;
27+
2528
/// {@macro in_app_notification_center_bloc}
2629
InAppNotificationCenterBloc({
2730
required DataRepository<InAppNotification> inAppNotificationRepository,
@@ -66,7 +69,7 @@ class InAppNotificationCenterBloc
6669
final response = await _inAppNotificationRepository.readAll(
6770
userId: userId,
6871
// Fetch the first page with a defined limit.
69-
pagination: const PaginationOptions(limit: 20),
72+
pagination: const PaginationOptions(limit: _notificationsFetchLimit),
7073
sort: [const SortOption('createdAt', SortOrder.desc)],
7174
);
7275

@@ -150,7 +153,10 @@ class InAppNotificationCenterBloc
150153
try {
151154
final response = await _inAppNotificationRepository.readAll(
152155
userId: userId,
153-
pagination: PaginationOptions(limit: 20, cursor: cursor),
156+
pagination: PaginationOptions(
157+
limit: _notificationsFetchLimit,
158+
cursor: cursor,
159+
),
154160
sort: [const SortOption('createdAt', SortOrder.desc)],
155161
);
156162

0 commit comments

Comments
 (0)