diff --git a/lib/helpers/groups_helper.dart b/lib/helpers/groups_helper.dart index b98ceda..90b545a 100644 --- a/lib/helpers/groups_helper.dart +++ b/lib/helpers/groups_helper.dart @@ -361,6 +361,14 @@ class GroupsHelper { .key) .execWithThrow(); + /// Delete a group's conversation + /// + /// Throws in case of failure + static Future 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 map) { return Group( diff --git a/lib/ui/screens/group_settings_screen.dart b/lib/ui/screens/group_settings_screen.dart index 18ca71c..ae538b0 100644 --- a/lib/ui/screens/group_settings_screen.dart +++ b/lib/ui/screens/group_settings_screen.dart @@ -301,6 +301,10 @@ class _GroupSettingsScreenState extends SafeState { ) : 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 { } } + 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"),