deleteKey method

Future<bool> deleteKey(
  1. LocationNotificationModel locationNotificationModel
)

Deletes originally created locationNotificationModel notification

Implementation

Future<bool> deleteKey(
    LocationNotificationModel locationNotificationModel) async {
  var atkeyMicrosecondId = locationNotificationModel.key!
      .split('requestlocation-')[1]
      .split('@')[0];

  var response =
      await AtLocationNotificationListener().atClientInstance!.getKeys(
            regex: 'requestlocation-$atkeyMicrosecondId',
          );

  var key = getAtKey(response[0]);

  locationNotificationModel.isAcknowledgment = true;

  var result = await AtClientManager.getInstance().atClient.delete(
        key,
      );

  /// remove notification
  key.sharedWith = locationNotificationModel.atsignCreator;
  if (!key.sharedWith!.contains('@')) {
    key.sharedWith = '@${key.sharedWith!}';
  }
  var resultForNotification =
      await AtClientManager.getInstance().atClient.delete(
            key,
          );
  _logger.finer(
      'deleteKey request location resultForNotification $resultForNotification');

  ///
  _logger.finer('$key delete operation $result');

  if (result) {
    KeyStreamService().removeData(key.key);
  }
  return result;
}