[Problem/Question]
The ChannelProvider seems to have an onBeforeSendUserMessage but not an onAfter… which is not great if you want to run an effect only on success.
I also noticed the events system has on onMessageReceived, but not an onMessageSent.
Is there any way to do this without having to manage all the input behaviour with a custom message input?
I don’t see why this the smart component Channel/components/MessageInput couldn’t take some callbacks for all those “onXxx” events. Would be 1 line to add there xD.
// If problem, please fill out the below. If question, please delete. [UIKit Version]
3.3.4
What specifically are you looking to achieve after the message has been sent?
In terms of event handlers only having an onMessageReceived, this is because these action upon websocket events that did not originate from the client. Typically, with the Core SDK, you’d have complete control over what you do when the event originates from your own client.
In it’s current form, what you’re looking for does not exist. You would need to overwrite the MessageInput component as it’s what contain the onSendMessage function.
onSendMessage and onBeforeMessageSend would accomplish essentially the same thing. The idea behind onBeforeMessageSend is to allow you to modify the default values that are sent along with the message. In design, onSendMessage would be built to do the same.
But what if the request fails? Then my application state is incorrect, as I have set state representing a successful event that has not been successful, right?
So actually the code change at line 150 wouldnt really just be props.onSendMessage() as that would happen before I guess as well. It would need to await the result of the internal sendMessage. Something like:
I think the best bet is for you to override the messageInput prop so you can access the underlying functionality. This way you have complete control over the life cycle of the message and can directly update your state accordingly.