mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Can add members to conversation
This commit is contained in:
parent
5d0ead5889
commit
bd73e265cc
@ -49,6 +49,15 @@ class ConversationsHelper {
|
|||||||
return response.getObject()["conversationID"];
|
return response.getObject()["conversationID"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Add a member to a conversation.
|
||||||
|
///
|
||||||
|
/// Throws in case of failure
|
||||||
|
static Future<void> addMember(int convID, int userID) async =>
|
||||||
|
await APIRequest.withLogin("conversations/addMember")
|
||||||
|
.addInt("convID", convID)
|
||||||
|
.addInt("userID", userID)
|
||||||
|
.execWithThrow();
|
||||||
|
|
||||||
/// Remove a member from a conversation.
|
/// Remove a member from a conversation.
|
||||||
///
|
///
|
||||||
/// Throws in case of failure
|
/// Throws in case of failure
|
||||||
|
@ -170,10 +170,7 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
keepFocusOnChoose: true,
|
keepFocusOnChoose: true,
|
||||||
label: tr("Add member"),
|
label: tr("Add member"),
|
||||||
enabled: _canAddMembers,
|
enabled: _canAddMembers,
|
||||||
onSelectUser: (user) => setState(() {
|
onSelectUser: (user) => _addMember(user)),
|
||||||
if (!_members.contains(user)) _members.insert(0, user);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
|
|
||||||
//Conversation members
|
//Conversation members
|
||||||
Column(
|
Column(
|
||||||
@ -229,6 +226,20 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _addMember(User user) async {
|
||||||
|
try {
|
||||||
|
if (_members.contains(user)) return;
|
||||||
|
|
||||||
|
if (isUpdating)
|
||||||
|
await ConversationsHelper.addMember(_conversation.id, user.id);
|
||||||
|
|
||||||
|
setState(() => _members.insert(0, user));
|
||||||
|
} catch (e, s) {
|
||||||
|
logError(e, s);
|
||||||
|
snack(context, tr("Failed to add member to conversation!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _removeMember(User user) async {
|
void _removeMember(User user) async {
|
||||||
try {
|
try {
|
||||||
if (isUpdating)
|
if (isUpdating)
|
||||||
|
Loading…
Reference in New Issue
Block a user