-
Notifications
You must be signed in to change notification settings - Fork 278
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
feat: implement message bounce flow #2254
Conversation
if (allowRetry) { | ||
handleClick = () => handleRetry(message); | ||
} else if (isBounced) { | ||
handleClick = () => setIsBounceDialogOpen(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a message is bounced, clicking on it should open a modal.
<Modal {...modalProps}> | ||
<MessageBounceProvider> | ||
<MessageBounceOptions onClose={modalProps.onClose} /> | ||
</MessageBounceProvider> | ||
</Modal> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modal renders MessageBounceOptions
(which can be overriden to customize the contents of the modal), and provides a couple of callbacks to it via context.
|
||
const handleEdit: ReactEventHandler = useCallback( | ||
(e) => { | ||
setEditingState(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clicking the "Edit" button switches the message to editing mode.
@@ -189,7 +189,7 @@ export const useSubmitHandler = < | |||
((!someLinkPreviewsLoading && attachmentsFromLinkPreviews.length > 0) || | |||
someLinkPreviewsDismissed); | |||
const sendOptions = linkPreviewsEnabled ? { skip_enrich_url } : undefined; | |||
if (message) { | |||
if (message && message.type !== 'error') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since bounced messages are ephemeral (as are all messages with type "error"), when editing them MessageInput
should just send a new message instead of updating an existing one - this check handles that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add test for this one please?
9d2a1bc
to
59a9eb3
Compare
Size Change: +9.95 kB (+1%) Total Size: 1.72 MB
ℹ️ View Unchanged
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2254 +/- ##
==========================================
+ Coverage 84.67% 84.88% +0.21%
==========================================
Files 328 343 +15
Lines 7458 7595 +137
Branches 1985 1996 +11
==========================================
+ Hits 6315 6447 +132
- Misses 969 974 +5
Partials 174 174 ☔ View full report in Codecov by Sentry. |
docusaurus/docs/React/components/contexts/message-bounce-context.mdx
Outdated
Show resolved
Hide resolved
docusaurus/docs/React/components/message-components/ui-components.mdx
Outdated
Show resolved
Hide resolved
docusaurus/docs/React/components/message-components/ui-components.mdx
Outdated
Show resolved
Hide resolved
## [11.8.0](v11.7.0...v11.8.0) (2024-02-13) ### Bug Fixes * adjust the first message rendering for DateSeparator in empty VirtualizedMessageList ([#2271](#2271)) ([8f490fa](8f490fa)) * export DefaultStreamChatGenerics ([#2266](#2266)) ([6a928f6](6a928f6)) * prevent mine attr from spreading on message actions box div ([#2270](#2270)) ([1625471](1625471)) * remove mark read functionality from ChannelPreview ([#2273](#2273)) ([3be1ec5](3be1ec5)) ### Features * implement message bounce flow ([#2254](#2254)) ([3878e2f](3878e2f)) * keep unread channel UI when unread channel is marked read on mount ([#2267](#2267)) ([2abe352](2abe352))
🎉 This PR is included in version 11.8.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎯 Goal
🚂 GetStream/stream-chat-js#1213
🚂 GetStream/stream-chat-css#264
In chats with moderation rules set up, message can bounce if its content is deemed potentially harmful. The author of a bounced message should then be presented with four alternatives:
🛠 Implementation details
This PR introduces a couple of new components, including the
MessageBounceModal
which is rendered byMessageSimple
when a bounced message is clicked.The contents of the modal (
MessageBounceOption
) is an overridable component that should ideally render three buttons for the first three alternative options listed above. The callbacks for said buttons are provided viaMessageBounceContext
.🎨 UI Changes
The chat in the screenshot has a semantic filter set up which is triggered by the word "midnight". Here's what a bounced message with the word "midnight" looks like:
Clicking on the bounced messages opens
MessageBounceModal
:Clicking "Edit Message" opens the standard editing UI:
To-Do and Next Steps
The design doc for this feature also features a notification banner with a button, which is displayed when a message bounces. Clicking the button should bring the user to the bounced message.
We don't have a way to have interactive elements within channel notifications at the moment, but this is going to be implemented in further PRs in two steps:
stream-chat-css
with udpated stylesstream-chat-js
with updates typesMessageBounceModal
andMessageBounceOptions
with tests