Skip to content

refactor(ui)!: re-wrote message actions and modals #2156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: v10.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions packages/stream_chat/lib/src/client/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -987,20 +987,35 @@
}
}

/// Retry the operation on the message based on the failed state.
/// Retries operations on a message based on its failed state.
///
/// For example, if the message failed to send, it will retry sending the
/// message and vice-versa.
/// This method examines the message's state and performs the appropriate
/// retry action:
/// - For [MessageState.sendingFailed], it attempts to send the message.
/// - For [MessageState.updatingFailed], it attempts to update the message.
/// - For [MessageState.deletingFailed], it attempts to delete the message.
/// with the same 'hard' parameter that was used in the original request
/// - For messages with [isBouncedWithError], it attempts to send the message.
Future<Object> retryMessage(Message message) async {
assert(message.state.isFailed, 'Message state is not failed');
assert(
message.state.isFailed || message.isBouncedWithError,

Check warning on line 1001 in packages/stream_chat/lib/src/client/channel.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat/lib/src/client/channel.dart#L1001

Added line #L1001 was not covered by tests
'Only failed or bounced messages can be retried',
);

return message.state.maybeWhen(
failed: (state, _) => state.when(
sendingFailed: () => sendMessage(message),
updatingFailed: () => updateMessage(message),
deletingFailed: (hard) => deleteMessage(message, hard: hard),
),
orElse: () => throw StateError('Message state is not failed'),
orElse: () {

Check warning on line 1011 in packages/stream_chat/lib/src/client/channel.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat/lib/src/client/channel.dart#L1011

Added line #L1011 was not covered by tests
// Check if the message is bounced with error.
if (message.isBouncedWithError) return sendMessage(message);

Check warning on line 1013 in packages/stream_chat/lib/src/client/channel.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat/lib/src/client/channel.dart#L1013

Added line #L1013 was not covered by tests

throw StateError(

Check warning on line 1015 in packages/stream_chat/lib/src/client/channel.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat/lib/src/client/channel.dart#L1015

Added line #L1015 was not covered by tests
'Only failed or bounced messages can be retried',
);
},
);
}

Expand Down
28 changes: 28 additions & 0 deletions packages/stream_chat_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## Upcoming Beta

🛑️ Breaking

- `StreamReactionPicker` now requires reactions to be explicitly handled via `onReactionPicked`. *(Automatic handling is no longer supported.)*
- `StreamMessageAction` is now generic `(StreamMessageAction<T>)`, enhancing type safety. Individual onTap callbacks have been removed; actions are now handled centrally by widgets like `StreamMessageWidget.onCustomActionTap` or modals using action types.
- `StreamMessageReactionsModal` no longer requires the `messageTheme` parameter. The theme now automatically derives from the `reverse` property.

For more details, please refer to the [migration guide](Unpublished).

✅ Added

- Added new `StreamMessageActionsBuilder` which provides a list of actions to be displayed in the message actions modal.
- Added new `StreamMessageActionConfirmationModal` for confirming destructive actions like delete or flag.
- Added new `StreamMessageModal` and `showStreamMessageModal` for consistent message-related modals with improved transitions and backdrop effects.
```dart
showStreamMessageModal(
context: context,
...other parameters,
builder: (context) => StreamMessageModal(
...other parameters,
headerBuilder: (context) => YourCustomHeader(),
contentBuilder: (context) => YourCustomContent(),
),
);
```
- Exported `StreamMessageActionsModal` and `StreamModeratedMessageActionsModal` which are now based on `StreamMessageModal` for consistent styling and behavior.

## Upcoming

🔄 Changed
Expand Down
5 changes: 5 additions & 0 deletions packages/stream_chat_flutter/dart_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The existence of this file prevents warnings about unrecognized tags when running Alchemist tests.

tags:
golden:
timeout: 15s
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class StreamChannelAvatar extends StatelessWidget {

final fallbackWidget = Center(
child: Text(
channel.name?[0] ?? '',
channel.name?.characters.firstOrNull ?? '',
style: TextStyle(
color: colorTheme.barsBg,
fontWeight: FontWeight.bold,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading