updateExistingLocationDataModel method

dynamic updateExistingLocationDataModel(
  1. List<LocationDataModel> _newLocationDataModel
)

update [allAtsignsLocationData_newLocationDataModel.receiver] with new values and sends updated location

Implementation

updateExistingLocationDataModel(
    List<LocationDataModel> _newLocationDataModel) async {
  List<String> _atsignsUpdated = [];
  for (var _tempLocationDataModel in _newLocationDataModel) {
    if (ifLocationDataAlreadyExists(_tempLocationDataModel)) {
      allAtsignsLocationData[_tempLocationDataModel.receiver]!
          .locationSharingFor = {
        ...allAtsignsLocationData[_tempLocationDataModel.receiver]!
            .locationSharingFor,
        ..._tempLocationDataModel.locationSharingFor,
      };

      if (!_atsignsUpdated.contains(_tempLocationDataModel.receiver)) {
        _atsignsUpdated.add(_tempLocationDataModel.receiver);
      }
    }
  }

  await SendLocationNotification()
      .sendLocationAfterDataUpdate(_atsignsUpdated);
}