stream-chat-react icon indicating copy to clipboard operation
stream-chat-react copied to clipboard

Support dynamic message actions based on the message / user

Open petyosi opened this issue 3 years ago • 4 comments

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.

petyosi avatar Mar 03 '22 12:03 petyosi

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.

petyosi avatar Mar 07 '22 13:03 petyosi

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
}

petyosi avatar Mar 08 '22 14:03 petyosi

@MartinCupela Do you have any plans to support this?

atsss avatar Mar 29 '23 10:03 atsss

@atsss for now, we keep it in our backlog without specific ETA.

MartinCupela avatar Apr 05 '23 21:04 MartinCupela