Skip to content

Commit 6d71de9

Browse files
authored
feat(ui): Update chat sdk defaults (#2691)
* Enable drafts and voice recording by default * update drafts default in sample app * Disable enforceUniqueReactions by default * Update changelog * Add draft mocks
1 parent d54f2fd commit 6d71de9

5 files changed

Lines changed: 15 additions & 5 deletions

File tree

packages/stream_chat_flutter/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
🛑️ Breaking
99

10+
- `StreamChatConfigurationData.draftMessagesEnabled` now defaults to `true`. Draft messages are enabled out of the box; pass `draftMessagesEnabled: false` to opt out.
11+
- `StreamChatConfigurationData.enforceUniqueReactions` now defaults to `false`. Users can add multiple distinct reaction types to a message by default; pass `enforceUniqueReactions: true` to restore the previous behaviour.
12+
- `StreamMessageComposer.enableVoiceRecording` now defaults to `true`. The voice recording button is shown out of the box; pass `enableVoiceRecording: false` to opt out.
1013
- `StreamMessageListView` had its large set of configuration and builder parameters reorganized. Behavior flags (e.g. `swipeToReply`, `markReadWhenAtTheBottom`, `showScrollToBottom`, `reverse`, `paginationLimit`, `scrollPhysics`, etc.) moved to `StreamMessageListViewConfiguration`, passed directly as `StreamMessageListView.config`. Custom builder callbacks (`headerBuilder`, `footerBuilder`, `loadingBuilder`, `emptyBuilder`, `errorBuilder`, `messageListBuilder`, `parentMessageBuilder`, `dateDividerBuilder`, `floatingDateDividerBuilder`, `threadSeparatorBuilder`, `unreadMessagesSeparatorBuilder`, `scrollToBottomBuilder`, `paginationLoadingIndicatorBuilder`, `spacingWidgetBuilder`, `systemMessageBuilder`, `ephemeralMessageBuilder`, `moderatedMessageBuilder`) moved to `StreamMessageListViewBuilders`, passed directly as `StreamMessageListView.builders`. The `messageBuilder` parameter is back at the root of the constructor as before.
1114
- Bumped `file_picker` to `^11.0.0` to resolve [#2599](https://github.com/GetStream/stream-chat-flutter/issues/2599). Apps depending on `file_picker` directly must also upgrade past `11.0.0`, which replaces the instance-based `FilePicker.platform.*` API with static `FilePicker.*` methods.
1215
- Renamed `StreamMessageComposer.messageInputController` parameter to `messageComposerController`.

packages/stream_chat_flutter/lib/src/message_input/stream_message_composer.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class StreamMessageComposer extends StatelessWidget {
6868
bool disableAttachments = false,
6969
int maxAttachmentSize = kDefaultMaxAttachmentSize,
7070
bool canAlsoSendToChannelFromThread = true,
71-
bool enableVoiceRecording = false,
71+
bool enableVoiceRecording = true,
7272
bool sendVoiceRecordingAutomatically = false,
7373
AudioRecorderFeedback voiceRecordingFeedback = const AudioRecorderFeedback(),
7474
UserMentionTileBuilder? userMentionsTileBuilder,

packages/stream_chat_flutter/lib/src/stream_chat_configuration.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class StreamChatConfigurationData {
159159
factory StreamChatConfigurationData({
160160
ReactionIconResolver? reactionIconResolver,
161161
bool? enforceUniqueReactions,
162-
bool draftMessagesEnabled = false,
162+
bool draftMessagesEnabled = true,
163163
MessagePreviewFormatter? messagePreviewFormatter,
164164
StreamImageCDN imageCDN = const StreamImageCDN(),
165165
List<StreamAttachmentWidgetBuilder>? attachmentBuilders,
@@ -169,7 +169,7 @@ class StreamChatConfigurationData {
169169
}) {
170170
return StreamChatConfigurationData._(
171171
reactionIconResolver: reactionIconResolver ?? const DefaultReactionIconResolver(),
172-
enforceUniqueReactions: enforceUniqueReactions ?? true,
172+
enforceUniqueReactions: enforceUniqueReactions ?? false,
173173
draftMessagesEnabled: draftMessagesEnabled,
174174
messagePreviewFormatter: messagePreviewFormatter ?? MessagePreviewFormatter(),
175175
imageCDN: imageCDN,

packages/stream_chat_flutter/test/src/mocks.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class MockChannel extends Mock implements Channel {
2222
ChannelCapability.uploadFile,
2323
],
2424
Stream<Event>? eventStream,
25-
}) : _eventStream = eventStream ?? const Stream.empty();
25+
}) : _eventStream = eventStream ?? const Stream.empty() {
26+
registerFallbackValue(DraftMessage());
27+
when(() => createDraft(any())).thenAnswer((_) async => CreateDraftResponse());
28+
when(deleteDraft).thenAnswer((_) async => EmptyResponse());
29+
when(() => deleteDraft(parentId: any(named: 'parentId'))).thenAnswer((_) async => EmptyResponse());
30+
}
2631

2732
@override
2833
final String type;
@@ -84,6 +89,8 @@ class MockChannelState extends Mock implements ChannelClientState {
8489
when(() => unreadCount).thenReturn(0);
8590
when(() => isUpToDate).thenReturn(true);
8691
when(() => read).thenReturn([]);
92+
when(() => draftStream).thenAnswer((_) => Stream.value(null));
93+
when(() => threadDraftStream(any())).thenAnswer((_) => Stream.value(null));
8794
}
8895
}
8996

sample_app/lib/config/sample_app_config.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SampleAppConfigData {
6363
bool enableDeleteForMe = false,
6464
bool enableMessageInfo = false,
6565
bool enableLocationSharing = false,
66-
bool draftMessagesEnabled = false,
66+
bool draftMessagesEnabled = true,
6767
bool enforceUniqueReactions = false,
6868
StreamReactionsType? reactionType,
6969
StreamReactionsPosition? reactionPosition,

0 commit comments

Comments
 (0)