diff --git a/packages/stream_chat_flutter/CHANGELOG.md b/packages/stream_chat_flutter/CHANGELOG.md index 3fee0e5dd2..25840adf91 100644 --- a/packages/stream_chat_flutter/CHANGELOG.md +++ b/packages/stream_chat_flutter/CHANGELOG.md @@ -15,6 +15,7 @@ 🐞 Fixed +- Fixed `StreamThreadPage` hiding the composer for a deleted parent message that already has replies, which can still be replied to. - Fixed the "Only visible to you" Giphy preview showing a delivery status. - Fixed channel list previews showing a "You:" or sender name prefix, and the delivery status, in front of a system message. - Fixed a deleted message hiding its replies count, which left its thread unreachable from the channel. diff --git a/packages/stream_chat_flutter/lib/src/pages/thread_page.dart b/packages/stream_chat_flutter/lib/src/pages/thread_page.dart index 00342721c0..3ca54fc8ab 100644 --- a/packages/stream_chat_flutter/lib/src/pages/thread_page.dart +++ b/packages/stream_chat_flutter/lib/src/pages/thread_page.dart @@ -8,7 +8,7 @@ import '../../stream_chat_flutter.dart'; /// out floating or regular according to the ambient [StreamSurfaceStyle]. Expects a /// [StreamChannel] ancestor. /// -/// The composer is omitted when [parent] is deleted. +/// The composer is omitted when [parent] is deleted and has no replies. /// /// ## Customizing this page /// @@ -101,7 +101,8 @@ class _StreamThreadPageState extends State { onBackPressed: widget.onBackPressed, ); - final composer = !widget.parent.isDeleted + final canReply = !widget.parent.isDeleted || (widget.parent.replyCount ?? 0) > 0; + final composer = canReply ? StreamMessageComposer( focusNode: _focusNode, messageComposerController: _messageComposerController, @@ -113,7 +114,7 @@ class _StreamThreadPageState extends State { appBar: appBar, bottom: composer, // Resolved from the slots so the body inset matches what the chrome draws. - // The bottom value is ignored when the composer is null (deleted parent). + // The bottom value is ignored when the composer is null. appBarSurfaceStyle: StreamThreadHeader.resolveSurfaceStyle(context), bottomSurfaceStyle: StreamMessageComposer.resolveSurfaceStyle(context), body: _ThreadBody( diff --git a/packages/stream_chat_flutter/test/src/channel/thread_page_test.dart b/packages/stream_chat_flutter/test/src/channel/thread_page_test.dart index 96048a8227..77d8cd7ce9 100644 --- a/packages/stream_chat_flutter/test/src/channel/thread_page_test.dart +++ b/packages/stream_chat_flutter/test/src/channel/thread_page_test.dart @@ -33,7 +33,7 @@ void main() { expect(_composerController(tester).message.parentId, 'parent-id'); }); - testWidgets('hides the composer when the parent message is deleted', (tester) async { + testWidgets('hides the composer when the deleted parent message has no replies', (tester) async { final parent = Message(id: 'parent-id', text: 'Hello world!', type: 'deleted'); await _pumpThreadPage(tester, parent: parent); @@ -41,6 +41,14 @@ void main() { expect(find.byType(StreamMessageComposer), findsNothing); }); + testWidgets('shows the composer when the deleted parent message has replies', (tester) async { + final parent = Message(id: 'parent-id', text: 'Hello world!', type: 'deleted', replyCount: 1); + + await _pumpThreadPage(tester, parent: parent); + + expect(find.byType(StreamMessageComposer), findsOneWidget); + }); + testWidgets('still shows the thread when the parent message is deleted', (tester) async { final parent = Message(id: 'parent-id', text: 'Hello world!', type: 'deleted');