This guide will familiarize you with the messageActions prop and allow you to customize the available actions on a message.
By default, messages in a MessageList component will have 'actions' that a channel member can perform on a message ('edit', 'delete', 'flag', 'mute', 'pin', 'react', 'reply', 'quote').
You're able to customize the availability of these actions in the MessageList component by taking advantage of the messageActions prop. This prop takes an array that can include any of the actions listed above.
By default...
- If a member has the role of 'admin', all of the above actions will be available.
- If a member has the role of 'user', they will have the options to flag, mute, reply, quote, and react.
In the case that you want to customize these actions, you can pass the messageActions prop an array.
In the case you want to customize actions based on the user role, a good practice is to create a function that conditionally returns the desired array of actions depending on the role.
const getMessageActions = () => {
if (client.user.role === "admin") {
return ["delete", "flag", "mute", "pin", "react", "reply"];
}
if (client.user.role === "user") {
return ["flag", "mute"];
}
};
In your MessageList component...
<MessageList messageActions={getMessageActions()}/>
Comments
0 comments
Please sign in to leave a comment.