chore: Fix reply to story

This commit is contained in:
Christian Pauly 2021-12-27 17:13:54 +01:00
parent b89d6884bd
commit a3f391b8ae
2 changed files with 18 additions and 5 deletions

View File

@ -2676,5 +2676,13 @@
"placeholders": {
"size": {}
}
},
"storyFrom": "Story from {date}: \n{body}",
"@storyFrom": {
"type": "text",
"placeholders": {
"date": {},
"body": {}
}
}
}

View File

@ -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<StoryPage> {
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<String>('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(