ifLocationDataAlreadyExists method

bool ifLocationDataAlreadyExists(
  1. LocationDataModel _newLocationDataModel
)

checks if _newLocationDataModel is already present in allAtsignsLocationData.

Implementation

bool ifLocationDataAlreadyExists(LocationDataModel _newLocationDataModel) {
  if (SendLocationNotification()
          .allAtsignsLocationData[_newLocationDataModel.receiver] !=
      null) {
    /// don't add and send again if already present
    var _receiverLocationDataModel = SendLocationNotification()
        .allAtsignsLocationData[_newLocationDataModel.receiver]!;

    if (_newLocationDataModel.locationSharingFor.keys.isEmpty) {
      return false;
    }

    var _id = _newLocationDataModel.locationSharingFor.keys.first;
    if (_receiverLocationDataModel.locationSharingFor[_id] != null) {
      return true;
    }
  }

  return false;
}