mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Delete conversation => leave conversation
This commit is contained in:
@ -123,30 +123,13 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
}
|
||||
|
||||
/// Handle conversation deletion request
|
||||
Future<void> _requestDeleteConversation(Conversation conversation) async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (c) {
|
||||
return AlertDialog(
|
||||
title: Text(tr("Delete conversation")),
|
||||
content: Text(tr(
|
||||
"Do you really want to remove this conversation from your list of conversations ? If you are the owner of this conversation, it will be completely deleted!")),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: Text(tr("cancel").toUpperCase()),
|
||||
),
|
||||
FlatButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: Text(
|
||||
tr("delete").toUpperCase(),
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
Future<void> _requestLeaveConversation(Conversation conversation) async {
|
||||
final result = await showConfirmDialog(
|
||||
context: context,
|
||||
message: conversation.isLastAdmin
|
||||
? tr(
|
||||
"Do you really want to leave this conversation ? As you are its last admin, it will be completely deleted!")
|
||||
: tr("Do you really want to leave this conversation ?"));
|
||||
|
||||
if (result == null || !result) return;
|
||||
|
||||
@ -154,9 +137,9 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
try {
|
||||
await _conversationsHelper.deleteConversation(conversation.id);
|
||||
} catch (e, s) {
|
||||
print("Failed to delete conversation! $e => $s");
|
||||
print("Failed to leave conversation! $e => $s");
|
||||
Scaffold.of(context).showSnackBar(
|
||||
SnackBar(content: Text(tr("Could not delete the conversation!"))));
|
||||
SnackBar(content: Text(tr("Could not leave the conversation!"))));
|
||||
}
|
||||
|
||||
// Reload the list of conversations
|
||||
@ -191,7 +174,7 @@ class _ConversationScreenState extends SafeState<ConversationsListScreen> {
|
||||
_openConversation(c.id);
|
||||
},
|
||||
onRequestUpdate: _updateConversation,
|
||||
onRequestDelete: _requestDeleteConversation,
|
||||
onRequestLeave: _requestLeaveConversation,
|
||||
);
|
||||
},
|
||||
itemCount: _list.length,
|
||||
|
Reference in New Issue
Block a user