getAllEventNotifications method

void getAllEventNotifications()

adds all 'createevent' notifications to atNotificationsSink

Implementation

void getAllEventNotifications() async {
  await SyncSecondary().callSyncSecondary(SyncOperation.syncSecondary);

  var response = await atClientInstance!.getKeys(
    regex: 'createevent-',
  );

  if (response.isEmpty) {
    EventLocationShare().init();
    notifyListeners();
    return;
  }

  response.forEach((key) {
    var eventKeyLocationModel = EventKeyLocationModel(key: key);
    allEventNotifications.add(eventKeyLocationModel);
  });

  allEventNotifications.forEach((notification) {
    var atKey = EventService().getAtKey(notification.key!);
    notification.atKey = atKey;
  });

  // TODO
  // filterBlockedContactsforEvents();

  for (var i = 0; i < allEventNotifications.length; i++) {
    AtValue? value = await (getAtValue(allEventNotifications[i].atKey!));
    if (value != null) {
      allEventNotifications[i].atValue = value;
    }
  }

  convertJsonToEventModel();
  filterPastEventsFromList();

  await checkForPendingEvents();

  notifyListeners();

  EventLocationShare().init();

  // ignore: unawaited_futures
  updateEventDataAccordingToAcknowledgedData();
}