Help with Custom Action Sheet and Message Reply Handling in Sendbird UIKit

I’m trying to recreate a custom message action sheet similar to what’s shown in the attached screenshot. I’m using

const { setMessageToEdit, setMessageToReply, messageToReply } = useContext(GroupChannelContexts.Fragment)

to set up actions on long press for “Edit” and “Reply.” When I press on Reply for example, I call setMessageToReply(msg) - However, I’m running into an issue where messageToReply doesn’t seem to update correctly when I pass in the selected message via onLongPress to my custom action sheet.

Additionally, I’m encountering a problem with fetching the channel’s message list. I’m using

const { messages, sendUserMessage, sendFileMessage } = useGroupChannelMessages(sdk, channel);

to get messages, but all messages have parentMessageId set to 0, even for those that are replies.

Questions:

  1. How can I ensure that messageToReply updates correctly when using a custom action sheet?

  2. Is there a way to retrieve the correct parentMessageId for reply messages using useGroupChannelMessages?

Any guidance on these issues would be greatly appreciated!

Hi @James_O_Connor.
Welcome to the Sendbird community!

  1. The rendering life cycle of the bottom sheet and the current channel behave differently.

Example:

<App>
  <BottomSheet />
  <Channel /> // Changes in rendering that occur here do not affect the BottomSheet.
</App>

Therefore, even if the messageToReply state in the Channel changes, the BottomSheet does not re-render and thus cannot use the updated messageToReply value from the Channel. The updated messageToReply must be passed when the BottomSheet is opened (rendered).

However, would it be possible to use the message that triggered the bottom sheet to open, instead of relying on messageToReply?


  1. The parentMessageId needs to be set with additional parameters when sending a message.

Example:

sendUserMessage({
  parentMessageId: messageToReply.messageId
});

For reference, you can check this in the actual UIKit source code: