checkForPendingLocations method
Updates any received notification with haveResponded
true, if already responded.
Implementation
Future<void> checkForPendingLocations() async {
await Future.forEach(allLocationNotifications,
(KeyLocationModel notification) async {
if (notification.locationNotificationModel!.key!
.contains(MixedConstants.SHARE_LOCATION)) {
if ((notification.locationNotificationModel!.atsignCreator !=
currentAtSign) &&
(!notification.locationNotificationModel!.isAccepted) &&
(!notification.locationNotificationModel!.isExited)) {
var atkeyMicrosecondId = notification.locationNotificationModel!.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.locationNotificationModel!.key!
.contains(MixedConstants.REQUEST_LOCATION)) {
if ((notification.locationNotificationModel!.atsignCreator ==
currentAtSign) &&
(!notification.locationNotificationModel!.isAccepted) &&
(!notification.locationNotificationModel!.isExited)) {
var atkeyMicrosecondId = notification.locationNotificationModel!.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;
}
}
}
});
}