checkLocationSharingForEventData method

void checkLocationSharingForEventData(
  1. EventNotificationModel eventNotificationModel
)

Checks current status of currentAtSign in an event and updates EventLocationShare location sending list.

Implementation

void checkLocationSharingForEventData(
    EventNotificationModel eventNotificationModel) {
  if ((eventNotificationModel.atsignCreator == currentAtSign)) {
    if (eventNotificationModel.isSharing!) {
      // ignore: unawaited_futures
      EventLocationShare().addMember(eventNotificationModel);
    } else {
      EventLocationShare().removeMember(eventNotificationModel.key);
    }
  } else {
    AtContact? currentGroupMember;
    for (var i = 0; i < eventNotificationModel.group!.members!.length; i++) {
      if (eventNotificationModel.group!.members!.elementAt(i).atSign ==
          currentAtSign) {
        currentGroupMember =
            eventNotificationModel.group!.members!.elementAt(i);
        break;
      }
    }

    if (currentGroupMember != null &&
        currentGroupMember.tags!['isAccepted'] == true &&
        currentGroupMember.tags!['isSharing'] == true &&
        currentGroupMember.tags!['isExited'] == false) {
      // ignore: unawaited_futures
      EventLocationShare().addMember(eventNotificationModel);
    } else {
      EventLocationShare().removeMember(eventNotificationModel.key);
    }
  }
}