Skip to content

Commit

Permalink
wrapped logic in the variable 'isVisibleForMessageType' for this chec…
Browse files Browse the repository at this point in the history
…k and used it
  • Loading branch information
dhairyashiil committed Dec 22, 2024
1 parent d09cfdc commit 2e21533
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/react/src/views/Message/MessageToolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,17 @@ export const MessageToolbox = ({
};

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

const isAllowedToEditMessage = userRoles.some((role) =>
editMessageRoles.has(role)
)
? true
: message.u._id === authenticatedUserId;

const isVisibleForMessageType =
message.files?.[0].type !== 'audio/mpeg' &&
message.files?.[0].type !== 'video/mp4';

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

0 comments on commit 2e21533

Please sign in to comment.