From 3c7795837c0a9669586bbcc33e2030ce7fbfc9c3 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 2 May 2020 15:38:02 +0200 Subject: [PATCH] Can invite a user to join a group --- lib/helpers/groups_helper.dart | 9 +++++++++ lib/ui/screens/group_members_screen.dart | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) 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(); } }