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:
parent
5773981750
commit
22f27a24de
@ -361,6 +361,14 @@ class GroupsHelper {
|
|||||||
.key)
|
.key)
|
||||||
.execWithThrow();
|
.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
|
/// Turn an API entry into a group object
|
||||||
Group _getGroupFromAPI(Map<String, dynamic> map) {
|
Group _getGroupFromAPI(Map<String, dynamic> map) {
|
||||||
return Group(
|
return Group(
|
||||||
|
@ -301,6 +301,10 @@ class _GroupSettingsScreenState extends SafeState<GroupSettingsScreen> {
|
|||||||
)
|
)
|
||||||
: Icon(Icons.group, size: 30),
|
: Icon(Icons.group, size: 30),
|
||||||
onChanged: (c) => _changeConversationVisibility(e, c),
|
onChanged: (c) => _changeConversationVisibility(e, c),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(Icons.delete),
|
||||||
|
onPressed: () => _deleteConversation(e),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
return tile;
|
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() {
|
Widget _buildGroupLogoArea() {
|
||||||
return SettingsSection(
|
return SettingsSection(
|
||||||
title: tr("Group logo"),
|
title: tr("Group logo"),
|
||||||
|
Loading…
Reference in New Issue
Block a user