stream-chat-react
stream-chat-react copied to clipboard
Support dynamic message actions based on the message / user
Motivation
Right now getMessageActions is called without any arguments. Integrators can't dynamically control the actions displayed per message.
Proposed solution
We should be able to support this custom behavior by passing the message and the user to the getMessageActions callback.
Acceptance Criteria
Updated getMessageActions signature.
Looking into this further, I propose the following implementation:
Introduce
messageActionsMapper?: (actions: MessageActionsArray<string>, message: StreamMessage) => MessageActionsArray<string>;
to the ComponentContext.
Call it here letting the integrator filter or add additional actions based on their logic.
Open question is if the integrator will have the necessary information to construct the action logic. This seems to be testable, as MessageActions.test.ts is already present.
As an alternative design, we can have customMessageActions accept a different structure (maybe an array of CustomMessageActions):
interface CustomMessageAction {
label: string
action: (message: StreamMessage, event: React.BaseSyntheticEvent) => void
isVisible?: (message: StreamMessage) => boolean
}
@MartinCupela Do you have any plans to support this?
@atsss for now, we keep it in our backlog without specific ETA.