checkForPendingEvents method

Future<void> checkForPendingEvents()

Updates any received notification with haveResponded true, if already responded.

Implementation

Future<void> checkForPendingEvents() async {
  // ignore: avoid_function_literals_in_foreach_calls
  allEventNotifications.forEach((notification) async {
    notification.eventNotificationModel!.group!.members!
        // ignore: avoid_function_literals_in_foreach_calls
        .forEach((member) async {
      if ((member.atSign == currentAtSign) &&
          (member.tags!['isAccepted'] == false) &&
          (member.tags!['isExited'] == false)) {
        var atkeyMicrosecondId = notification.eventNotificationModel!.key!
            .split('createevent-')[1]
            .split('@')[0];
        var acknowledgedKeyId = 'eventacknowledged-$atkeyMicrosecondId';
        var allRegexResponses =
            await atClientManager.atClient.getKeys(regex: acknowledgedKeyId);
        // ignore: unnecessary_null_comparison
        if ((allRegexResponses != null) && (allRegexResponses.isNotEmpty)) {
          notification.haveResponded = true;
        }
      }
    });
  });
}