-
Notifications
You must be signed in to change notification settings - Fork 270
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: allow custom attachments #2383
Conversation
Size Change: +15.4 kB (+1%) Total Size: 2.14 MB
ℹ️ View Unchanged
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2383 +/- ##
==========================================
+ Coverage 84.87% 85.31% +0.43%
==========================================
Files 386 392 +6
Lines 8908 9021 +113
Branches 2274 2320 +46
==========================================
+ Hits 7561 7696 +135
+ Misses 1160 1118 -42
- Partials 187 207 +20 ☔ View full report in Codecov by Sentry. |
docusaurus/docs/React/guides/message-input/attachment-previews.mdx
Outdated
Show resolved
Hide resolved
upsertAttachments: ( | ||
attachments: (Attachment<StreamChatGenerics> | LocalAttachment<StreamChatGenerics>)[], | ||
) => void; |
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.
upsertAttachments: ( | |
attachments: (Attachment<StreamChatGenerics> | LocalAttachment<StreamChatGenerics>)[], | |
) => void; | |
upsertAttachments: ( | |
attachments: (Attachment<StreamChatGenerics> | LocalAttachment<StreamChatGenerics>)[], | |
) => void; |
nit/feat: Could integrators benefit from patch function?
upsertAttachments((currentAttachments) => {
return currentAttachments.map((attachment) => {
if (attachment.id !== arbitraryId) return attachment;
return { ...attachment, localMetadata: { ...attachment.localMetadata, customThing: 123 } };
});
});
Co-authored-by: Anton Arnautov <43254280+arnautov-anton@users.noreply.github.com>
…nto feat/allow-custom-attachments
if (attachmentIndex === -1) { | ||
attachments.push(actionAttachment); | ||
} else { | ||
const upsertedAttachment = mergeDeep( |
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.
@arnautov-anton regarding your question about patching the attachments. It happens here.
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.
🌮
🎉 This PR is included in version 11.18.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎯 Goal
Allow integrators to add custom attachments to a composed message. This is possible via
upsertAttachment
andremoveAttachment
functions exposed viaMessageInputContextValue
. Both functions expect arrays of values to perform batch updates.The integrators can customize the look of custom attachments by providing custom components:
UnsupportedAttachment
toAttachment
component wrapper.UnknownAttachment
toAttachmentPreviewList
component wrapper.Attachment
andAttachmentPreviewList
wrappers are then passed toChannel
as props.🎨 UI Changes
Unknown attachments are by default rendered as follows: