acceptInvite method

Future<void> acceptInvite(
  1. int inviteId
)

Accepts the invite with the given inviteId.

Implementation

Future<void> acceptInvite(int inviteId) async {
  if (!state.hasData) {
    log('Cannot accept invite: No plan loaded.');

    return;
  }

  try {
    data(
      state.requireData.map((invite) {
        if (invite.id == inviteId) {
          return invite.copyWith(status: PlanInviteStatus.accepted);
        }

        return invite;
      }).toList(),
    );

    await _invites.acceptInvite(
      _auth.state.requireData[Webservice.lb_planner_api],
      inviteId,
    );

    await captureEvent('invite_accepted');

    await _plan.build(this);
  } catch (e, st) {
    log('Failed to accept invite.', e, st);

    return;
  }
}