onDeleteOwnMessage method
void
onDeleteOwnMessage( - dynamic context,
- dynamic ref,
- String messageId,
- String roomId,
)
Implementation
void onDeleteOwnMessage(
BuildContext context,
WidgetRef ref,
String messageId,
String roomId,
) {
final chatInputNotifier = ref.watch(chatInputProvider.notifier);
showAdaptiveDialog(
context: context,
builder: (context) => DefaultDialog(
title: Text(L10n.of(context).areYouSureYouWantToDeleteThisMessage),
actions: <Widget>[
OutlinedButton(
onPressed: () => Navigator.pop(context),
child: Text(L10n.of(context).no),
),
ActerPrimaryActionButton(
onPressed: () async {
try {
final convo = await ref.read(chatProvider(roomId).future);
if (convo == null) {
throw RoomNotFound();
}
await convo.redactMessage(
messageId,
ref.read(myUserIdStrProvider),
null,
null,
);
chatInputNotifier.unsetSelectedMessage();
if (context.mounted) {
Navigator.pop(context);
}
} catch (e, s) {
_log.severe('Redacting message failed', e, s);
if (!context.mounted) return;
EasyLoading.showError(
L10n.of(context).redactionFailed(e),
duration: const Duration(seconds: 3),
);
Navigator.pop(context);
}
},
child: Text(L10n.of(context).yes),
),
],
),
);
}