getPendingNotifications method

Future<(NotificationFailure?, List<NotificationEntity>?)> getPendingNotifications()

Gets all pending notifications from both repositories.

Implementation

Future<(NotificationFailure?, List<NotificationEntity>?)>
getPendingNotifications() async {
  if (!_isInitialized) {
    return (
      NotificationFailure.initialization(
        details: 'Notification manager not initialized',
      ),
      null,
    );
  }

  // Get from both repositories and merge
  final (
    NotificationFailure? localError,
    List<NotificationEntity>? localNotifications,
  ) = await _localRepository
      .getPendingNotifications();
  final (
    NotificationFailure? firebaseError,
    List<NotificationEntity>? firebaseNotifications,
  ) = await _firebaseRepository
      .getPendingNotifications();

  // Merge results
  final List<NotificationEntity> allNotifications = <NotificationEntity>[
    ...?localNotifications,
    ...?firebaseNotifications,
  ];

  // Return first error if any, otherwise success with merged notifications
  return (
    localError ?? firebaseError,
    allNotifications.isEmpty ? null : allNotifications,
  );
}