From c67df2e14f693b3cdd30552d4fde0d456a8726d8 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sun, 14 Jan 2024 14:27:05 +0100 Subject: [PATCH] fix: Forward arbitrary message content --- assets/l10n/intl_en.arb | 7 +++++++ lib/pages/chat_list/chat_list_item.dart | 21 ++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 539ac47f..a8a59566 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2409,5 +2409,12 @@ "url": {}, "error": {} } + }, + "forwardMessageTo": "Forward message to {roomName}?", + "@forwardMessageTo": { + "type": "text", + "placeholders": { + "roomName": {} + } } } \ No newline at end of file diff --git a/lib/pages/chat_list/chat_list_item.dart b/lib/pages/chat_list/chat_list_item.dart index c04d6878..fbaa13a9 100644 --- a/lib/pages/chat_list/chat_list_item.dart +++ b/lib/pages/chat_list/chat_list_item.dart @@ -126,12 +126,23 @@ class ChatListItem extends StatelessWidget { ); Matrix.of(context).shareContent = null; } else { - final text = shareContent.tryGet('body'); - Matrix.of(context).shareContent = null; - context.go( - '/rooms/${room.id}?body=$text', + final consent = await showOkCancelAlertDialog( + context: context, + title: L10n.of(context)!.forward, + message: L10n.of(context)!.forwardMessageTo( + room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)), + ), + okLabel: L10n.of(context)!.forward, + cancelLabel: L10n.of(context)!.cancel, ); - return; + if (consent == OkCancelResult.cancel) { + Matrix.of(context).shareContent = null; + return; + } + if (consent == OkCancelResult.ok) { + room.sendEvent(shareContent); + Matrix.of(context).shareContent = null; + } } }