Skip to content

Commit

Permalink
Update visibility logic for 'Edit' button
Browse files Browse the repository at this point in the history
  • Loading branch information
dhairyashiil committed Dec 22, 2024
1 parent 043209c commit 354265a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/react/src/views/Message/MessageToolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,11 @@ export const MessageToolbox = ({
};

const isAllowedToPin = userRoles.some((role) => pinRoles.has(role));

const isAllowedToEditMessage = userRoles.some((role) =>
editMessageRoles.has(role)
)
? true
: message.u._id === authenticatedUserId &&
message.files?.[0].type !== 'audio/mpeg' &&
message.files?.[0].type !== 'video/mp4';

: message.u._id === authenticatedUserId;
const options = useMemo(
() => ({
reply: {
Expand Down Expand Up @@ -134,7 +130,10 @@ export const MessageToolbox = ({
id: 'edit',
onClick: () => handleEditMessage(message),
iconName: 'edit',
visible: isAllowedToEditMessage,
visible:
isAllowedToEditMessage &&
message.files?.[0].type !== 'audio/mpeg' &&
message.files?.[0].type !== 'video/mp4',
color: isEditing ? 'secondary' : 'default',
ghost: !isEditing,
},
Expand Down

0 comments on commit 354265a

Please sign in to comment.