diff --git a/lib/helpers/groups_helper.dart b/lib/helpers/groups_helper.dart index 849bba3..fa111aa 100644 --- a/lib/helpers/groups_helper.dart +++ b/lib/helpers/groups_helper.dart @@ -268,6 +268,15 @@ class GroupsHelper { .map((f) => _apiToGroupMembership(f)) .toList()); + /// Invite a user to join a group + /// + /// Throws an exception in case of failure + static Future sendInvitation(int groupID, int userID) async => + APIRequest.withLogin("groups/invite") + .addInt("group_id", groupID) + .addInt("userID", userID) + .execWithThrow(); + /// Cancel a group membership invitation /// /// Throws an exception in case of failure diff --git a/lib/ui/screens/group_members_screen.dart b/lib/ui/screens/group_members_screen.dart index 4cf4b1f..a0da717 100644 --- a/lib/ui/screens/group_members_screen.dart +++ b/lib/ui/screens/group_members_screen.dart @@ -96,11 +96,13 @@ class _GroupMembersScreenState extends State { final userID = await showPickUserDialog(context); if (userID == null) return; - print("Invite user: $userID"); + await GroupsHelper.sendInvitation(widget.groupID, userID); } catch (e, s) { print("Could not invite a user! $e\n$s"); showSimpleSnack(context, tr("Could not invite a user!")); } + + _key.currentState.refresh(); } }