addDataToList method

Future addDataToList(
  1. EventNotificationModel eventNotificationModel, {
  2. String? receivedkey,
})

Adds new EventKeyLocationModel data for new received notification

Implementation

Future<dynamic> addDataToList(EventNotificationModel eventNotificationModel,
    {String? receivedkey}) async {
  /// so, that we don't add any expired event
  if (isPastNotification(eventNotificationModel)) {
    return;
  }

  /// with rSDK we can get previous notification, this will restrict us to add one notification twice
  for (var _eventNotification in allEventNotifications) {
    if (_eventNotification.eventNotificationModel != null &&
        _eventNotification.eventNotificationModel!.key ==
            eventNotificationModel.key) {
      return;
    }
  }

  var tempEventKeyLocationModel = EventKeyLocationModel();
  tempEventKeyLocationModel.eventNotificationModel = eventNotificationModel;
  allEventNotifications.insert(0,
      tempEventKeyLocationModel); // last item to come in would be at the top of the list

  notifyListeners();

  /// Add in SendLocation map only if I am creator,
  /// for members, will be added on first action on the event
  if (compareAtSign(eventNotificationModel.atsignCreator!, currentAtSign!)) {
    await checkLocationSharingForEventData(
        tempEventKeyLocationModel.eventNotificationModel!);
  }

  return tempEventKeyLocationModel;
}