fixed bug that prevents sending messages if reply was triggered in a different chat
This commit is contained in:
@@ -11,6 +11,7 @@ import '../../../../api/marianumcloud/talk/send_message/send_message_params.dart
|
||||
import '../../../../api/marianumcloud/talk/share_files_to_chat.dart';
|
||||
import '../../../../api/marianumcloud/webdav/webdav_api.dart';
|
||||
import '../../../../state/app/modules/chat/bloc/chat_bloc.dart';
|
||||
import '../../../../state/app/modules/chat/bloc/chat_state.dart';
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../widget/async_action_button.dart';
|
||||
import '../../../../widget/demo_restricted.dart';
|
||||
@@ -216,11 +217,27 @@ class _ChatTextfieldState extends State<ChatTextfield> {
|
||||
_setDraft(newText);
|
||||
}
|
||||
|
||||
/// Reply target for the next send, or null when there is none. Requires the
|
||||
/// referenced message to sit in this room's loaded history — the same
|
||||
/// criterion the reply banner renders on, so what the user sees is what gets
|
||||
/// sent. Talk rejects the whole message when the parent id is foreign to the
|
||||
/// room, so a leftover reference would otherwise block the chat entirely.
|
||||
String? _replyTargetFor(ChatState? chatState) {
|
||||
final referenceId = chatState?.referenceMessageId;
|
||||
if (referenceId == null) return null;
|
||||
if (chatState!.currentToken != widget.sendToToken) return null;
|
||||
final messages = chatState.chatResponse?.data;
|
||||
if (messages == null || !messages.any((e) => e.id == referenceId)) {
|
||||
return null;
|
||||
}
|
||||
return referenceId.toString();
|
||||
}
|
||||
|
||||
Future<void> _sendMessage(ChatBloc chatBloc) async {
|
||||
if (_textBoxController.text.isEmpty) return;
|
||||
if (guardDemoAction(context)) return;
|
||||
final text = _textBoxController.text;
|
||||
final replyTo = chatBloc.state.data?.referenceMessageId?.toString();
|
||||
final replyTo = _replyTargetFor(chatBloc.state.data);
|
||||
final ownToken = widget.sendToToken;
|
||||
setState(() => _sendError = null);
|
||||
await SendMessage(
|
||||
|
||||
Reference in New Issue
Block a user