addDataToList method

Future addDataToList(
  1. EventNotificationModel eventNotificationModel
)

Adds new EventKeyLocationModel data for new received notification

Implementation

Future<dynamic> addDataToList(
    EventNotificationModel eventNotificationModel) async {
  String newLocationDataKeyId;
  String? key;
  newLocationDataKeyId =
      eventNotificationModel.key!.split('createevent-')[1].split('@')[0];

  var keys = <String>[];
  keys = await atClientInstance!.getKeys(
    regex: 'createevent-',
  );

  keys.forEach((regex) {
    if (regex.contains('$newLocationDataKeyId')) {
      key = regex;
    }
  });

  print('key $key');

  if (key == null) {
    return;
  }

  var tempEventKeyLocationModel = EventKeyLocationModel(key: key);
  // eventNotificationModel.key = key;
  tempEventKeyLocationModel.atKey = EventService().getAtKey(key!);
  tempEventKeyLocationModel.atValue =
      await getAtValue(tempEventKeyLocationModel.atKey!);
  tempEventKeyLocationModel.eventNotificationModel = eventNotificationModel;
  allEventNotifications.add(tempEventKeyLocationModel);

  notifyListeners();

  // if ((tempHyridNotificationModel.locationNotificationModel!.isSharing)) {
  //   if (tempHyridNotificationModel.locationNotificationModel!.atsignCreator ==
  //       currentAtSign) {
  //     // ignore: unawaited_futures
  //     SendLocationNotification()
  //         .addMember(tempHyridNotificationModel.locationNotificationModel);
  //   }
  // }
  checkLocationSharingForEventData(
      tempEventKeyLocationModel.eventNotificationModel!);

  return tempEventKeyLocationModel;
}