inviteMessage function

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

Message builder for NotificationType.invite.

Implementation

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

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

      return Skeletonizer(
        enabled: userName == null || notification.context == null,
        child: Text(
          '${userName ?? 'Loading'} invited you to join their plan!',
        ),
      );
    },
  );
}