feat: Added delete dialog and added dismiss dialog in case of message flagged
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import 'dart:convert';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
@@ -253,6 +254,34 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
try {
|
try {
|
||||||
await client.flagMessage(widget.message.id);
|
await client.flagMessage(widget.message.id);
|
||||||
_showDismissAlert();
|
_showDismissAlert();
|
||||||
|
} catch (err) {
|
||||||
|
if (json.decode(err?.body ?? {})['code'] == 4) {
|
||||||
|
_showDismissAlert();
|
||||||
|
} else {
|
||||||
|
_showErrorAlert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showDeleteDialog() async {
|
||||||
|
var answer = await showConfirmationDialog(context,
|
||||||
|
title: 'Delete message',
|
||||||
|
icon: StreamSvgIcon.flag(
|
||||||
|
color: StreamChatTheme.of(context).colorTheme.accentRed,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
question: 'Are you sure you want to permanently delete this\nmessage?',
|
||||||
|
okText: 'DELETE',
|
||||||
|
cancelText: 'CANCEL');
|
||||||
|
|
||||||
|
if (answer) {
|
||||||
|
try {
|
||||||
|
Navigator.pop(context);
|
||||||
|
StreamChat.of(context).client.deleteMessage(
|
||||||
|
widget.message,
|
||||||
|
StreamChannel.of(context).channel.cid,
|
||||||
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
_showErrorAlert();
|
_showErrorAlert();
|
||||||
}
|
}
|
||||||
@@ -455,11 +484,7 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
_showDeleteDialog();
|
||||||
StreamChat.of(context).client.deleteMessage(
|
|
||||||
widget.message,
|
|
||||||
StreamChannel.of(context).channel.cid,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user