getAllNotifications method

void getAllNotifications()

adds all share and request location notifications to atNotificationsSink

Implementation

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

  var allResponse = await atClientInstance!.getKeys(
    regex: 'sharelocation-',
  );

  var allRequestResponse = await atClientInstance!.getKeys(
    regex: 'requestlocation-',
  );

  allResponse = [...allResponse, ...allRequestResponse];

  if (allResponse.isEmpty) {
    SendLocationNotification().init(atClientInstance);
    notifyListeners();
    return;
  }

  allResponse.forEach((key) {
    if ('@${key.split(':')[1]}'.contains(currentAtSign!)) {
      var tempHyridNotificationModel = KeyLocationModel(key: key);
      allLocationNotifications.add(tempHyridNotificationModel);
    }
  });

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

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

  convertJsonToLocationModel();
  filterData();

  await checkForPendingLocations();

  notifyListeners();
  updateEventAccordingToAcknowledgedData();
  checkForDeleteRequestAck();

  SendLocationNotification().init(atClientInstance);
}