openOptions method

Future<void> openOptions(
  1. BuildContext context,
  2. Widget profilePhoto
)

Implementation

Future<void> openOptions(BuildContext context, Widget profilePhoto) async {
  if (value!.documentID != member!.documentID) {
    String key = FollowerHelper.getKey(value!.documentID, member!.documentID);
    var following =
        await followingRepository(appId: app.documentID)!.get(key);
    if (following == null) {
      var followRequest =
          await followRequestRepository(appId: app.documentID)!.get(key);
      if ((followRequest == null) ||
          (followRequest.status ==
              FollowRequestStatus.followRequestAccepted)) {
        // allow to re-request to follow, if the follower has removed the follower but accepted in the past
        openAckNackDialog(app, context, '${app.documentID}/requestfollow',
            title: 'Request to follow',
            message: 'Request to follow this person?', onSelection: (value) {
          if (value == 0) {
            _invite(context);
          }
        });
      } else {
        if (followRequest.status == FollowRequestStatus.followRequestDenied) {
          openAckNackDialog(app, context, '${app.documentID}/invite',
              title: 'Request to follow',
              message:
                  "Request to follow this person? You've requested this before and this was declined.",
              onSelection: (value) {
            if (value == 0) {
              _invite(context);
            }
          });
        } else {
          if (followRequest.status ==
              FollowRequestStatus.followRequestPending) {
            openErrorDialog(app, context, '${app.documentID}/_error',
                title: 'Error',
                errorMessage:
                    "You have already requested to follow this person and the request is pending.");
/*
          } else {
            openErrorDialog(app, context, app.documentID + '/_error',
                title: 'Error',
                errorMessage:
                    "You have already requested to follow this person and this was accepted.");
*/
          }
        }
      }
    } else {
      openErrorDialog(app, context, '${app.documentID}/_error',
          title: 'Error',
          errorMessage: 'You are already following this person');
    }
  } else {
    openErrorDialog(app, context, '${app.documentID}/_error',
        title: 'Error',
        errorMessage: 'This is you. No point following yourself');
  }
}