Hi,
I am using SfChat control and want to know how to cancel adding the message to the collection if my API call fails for some reason.
Currently I am looking at the documentation and it says to use the below:
public void Execute(object parameter)
{
(parameter as SendMessageEventArgs).Handled = true;
}
The above works but I need to set this conditionally like the below (which doesn't seem to work) - e.g the message is always added to the local collection - even if the API call to save the message on the server returns false (it failed)
var result = await api_call_to_save_message(newMessage);
if (!result)
{
(parameter as SendMessageEventArgs).Handled = true;
_dialogService.DisplayAlert('Success - Message Saved');
}
else
{
(parameter as SendMessageEventArgs).Handled = false;
_dialogService.DisplayAlert('Error - Message Failed To Save - do you want to try sending again?');
}
Does SfChat control have a way/event/command (using MVVM) to only add the new message to the local collection if the check is passed? Or the ability to remove the failed message from the collection?