feat(ui): add ability to override delete confirm button tap.

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-06-15 19:15:04 +05:30
committed by xsahil03x
parent fe60a72ab3
commit d9be58ab8f
2 changed files with 28 additions and 23 deletions
@@ -19,6 +19,7 @@ class MessageActionsModal extends StatefulWidget {
this.showDeleteMessage = true,
this.showEditMessage = true,
this.onReplyTap,
this.onConfirmDeleteTap,
this.onThreadReplyTap,
this.showCopyMessage = true,
this.showReplyMessage = true,
@@ -44,6 +45,9 @@ class MessageActionsModal extends StatefulWidget {
/// The action to perform when "reply" is tapped
final OnMessageTap? onReplyTap;
/// The action to perform when delete confirmation button is tapped.
final Future<void> Function(Message)? onConfirmDeleteTap;
/// Message in focus for actions
final Message message;
@@ -363,7 +367,12 @@ class _MessageActionsModalState extends State<MessageActionsModal> {
if (answer == true) {
try {
Navigator.of(context).pop();
await StreamChannel.of(context).channel.deleteMessage(widget.message);
final onConfirmDeleteTap = widget.onConfirmDeleteTap;
if (onConfirmDeleteTap != null) {
await onConfirmDeleteTap(widget.message);
} else {
await StreamChannel.of(context).channel.deleteMessage(widget.message);
}
} catch (err) {
_showErrorAlertBottomSheet();
}