Skip to content
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

Fix: The 'Copy' option functionality is now working for File messages #716

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
30 changes: 17 additions & 13 deletions packages/react/src/views/Message/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,24 @@ const Message = ({
};

const handleCopyMessage = async (msg) => {
navigator.clipboard
.writeText(msg.msg)
.then(() => {
dispatchToastMessage({
type: 'success',
message: 'Message copied successfully',
});
})
.catch(() => {
dispatchToastMessage({
type: 'error',
message: 'Error in copying message',
});
const textToCopy =
msg.msg ||
(msg.attachments && msg.attachments[0]
? msg.attachments[0].description || msg.attachments[0].title
: '');

try {
await navigator.clipboard.writeText(textToCopy);
dispatchToastMessage({
type: 'success',
message: 'Message copied successfully',
});
} catch (error) {
dispatchToastMessage({
type: 'error',
message: 'Error in copying message',
});
}
};

const getMessageLink = async (id) => {
Expand Down
Loading