1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 12:59:21 +00:00

Can delete a group conversation

This commit is contained in:
Pierre HUBERT 2021-04-06 17:46:05 +02:00
parent 5773981750
commit 22f27a24de
2 changed files with 28 additions and 0 deletions

View File

@ -361,6 +361,14 @@ class GroupsHelper {
.key)
.execWithThrow();
/// Delete a group's conversation
///
/// Throws in case of failure
static Future<void> deleteConversation(int convID) async =>
await APIRequest.withLogin("groups/delete_conversation")
.addInt("conv_id", convID)
.execWithThrow();
/// Turn an API entry into a group object
Group _getGroupFromAPI(Map<String, dynamic> map) {
return Group(

View File

@ -301,6 +301,10 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
)
: Icon(Icons.group, size: 30),
onChanged: (c) => _changeConversationVisibility(e, c),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () => _deleteConversation(e),
),
);
return tile;
@ -365,6 +369,22 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
}
}
void _deleteConversation(Conversation conv) async {
try {
if (!await showConfirmDialog(
context: context,
message: tr("Do you really want to delete this conversation?")))
return;
await GroupsHelper.deleteConversation(conv.id);
_key.currentState.refresh();
} catch (e, s) {
logError(e, s);
snack(context, tr("Failed to delete conversation!"));
}
}
Widget _buildGroupLogoArea() {
return SettingsSection(
title: tr("Group logo"),