inviteAcceptedMessage function

Widget inviteAcceptedMessage(
  1. BuildContext context,
  2. Notification notification
)

Message builder for NotificationType.inviteAccepted.

Implementation

Widget inviteAcceptedMessage(BuildContext context, Notification notification) {
  final plan = context.watch<CalendarPlanRepository>();
  final users = context.watch<UsersRepository>();

  return FutureBuilder(
    future: plan.getInvites(id: notification.context),
    builder: (context, snapshot) {
      final invite = snapshot.data?.firstOrNull;
      final userName = invite != null
          ? users.state.data
              ?.filter(
                ids: [
                  invite.invitedUserId,
                ],
              )
              .firstOrNull
              ?.fullname
          : null;

      return Skeletonizer(
        enabled: userName == null || notification.context == null,
        child: Text(
          '$userName accepted your invitation!',
        ),
      );
    },
  );
}