checkForPendingLocations method

Future<void> checkForPendingLocations()

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

Implementation

Future<void> checkForPendingLocations() async {
  allLocationNotifications.forEach((notification) async {
    if (notification.key!.contains(MixedConstants.SHARE_LOCATION)) {
      if ((notification.locationNotificationModel!.atsignCreator !=
              currentAtSign) &&
          (!notification.locationNotificationModel!.isAccepted) &&
          (!notification.locationNotificationModel!.isExited)) {
        var atkeyMicrosecondId =
            notification.key!.split('sharelocation-')[1].split('@')[0];
        var acknowledgedKeyId =
            'sharelocationacknowledged-$atkeyMicrosecondId';
        var allRegexResponses =
            await atClientInstance!.getKeys(regex: acknowledgedKeyId);
        // ignore: unnecessary_null_comparison
        if ((allRegexResponses != null) && (allRegexResponses.isNotEmpty)) {
          notification.haveResponded = true;
        }
      }
    }

    if (notification.key!.contains(MixedConstants.REQUEST_LOCATION)) {
      if ((notification.locationNotificationModel!.atsignCreator ==
              currentAtSign) &&
          (!notification.locationNotificationModel!.isAccepted) &&
          (!notification.locationNotificationModel!.isExited)) {
        var atkeyMicrosecondId =
            notification.key!.split('requestlocation-')[1].split('@')[0];
        var acknowledgedKeyId =
            'requestlocationacknowledged-$atkeyMicrosecondId';
        var allRegexResponses =
            await atClientInstance!.getKeys(regex: acknowledgedKeyId);
        // ignore: unnecessary_null_comparison
        if ((allRegexResponses != null) && (allRegexResponses.isNotEmpty)) {
          notification.haveResponded = true;
        }
      }
    }
  });
}