From a3f391b8ae851d7b32670e513b38b31a86dea5b2 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 27 Dec 2021 17:13:54 +0100 Subject: [PATCH] chore: Fix reply to story --- assets/l10n/intl_en.arb | 8 ++++++++ lib/pages/story/story_page.dart | 15 ++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index ab52561d..beb6e378 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2676,5 +2676,13 @@ "placeholders": { "size": {} } + }, + "storyFrom": "Story from {date}: \n{body}", + "@storyFrom": { + "type": "text", + "placeholders": { + "date": {}, + "body": {} + } } } diff --git a/lib/pages/story/story_page.dart b/lib/pages/story/story_page.dart index abd06c53..6e45f4d8 100644 --- a/lib/pages/story/story_page.dart +++ b/lib/pages/story/story_page.dart @@ -15,6 +15,7 @@ import 'package:video_player/video_player.dart'; import 'package:vrouter/vrouter.dart'; import 'package:fluffychat/pages/story/story_view.dart'; +import 'package:fluffychat/utils/date_time_extension.dart'; import 'package:fluffychat/utils/localized_exception_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions.dart/client_stories_extension.dart'; import 'package:fluffychat/utils/platform_infos.dart'; @@ -67,16 +68,20 @@ class StoryPageController extends State { void replyAction([String? message]) async { message ??= replyController.text; + final currentEvent = this.currentEvent; + if (currentEvent == null) return; setState(() { replyLoading = true; }); try { final client = Matrix.of(context).client; - final roomId = await client.startDirectChat(currentEvent!.senderId); - await client.getRoomById(roomId)!.sendTextEvent( - message, - inReplyTo: currentEvent!, - ); + final roomId = await client.startDirectChat(currentEvent.senderId); + var replyText = L10n.of(context)!.storyFrom( + currentEvent.originServerTs.localizedTime(context), + currentEvent.content.tryGet('body') ?? ''); + replyText = replyText.split('\n').map((line) => '> $line').join('\n'); + message = '$replyText\n\n$message'; + await client.getRoomById(roomId)!.sendTextEvent(message); replyController.clear(); replyFocus.unfocus(); ScaffoldMessenger.of(context).showSnackBar(