I am toying around with the Chat UI and trying some different things out to see how they work, and to figure out what to use in production..
When using an ItemConverter, it seems to work great in instances where one input item results in one TextMessage, but what about in situations where one item may require 2 outputs? Can this be handled with an ItemConverter? (Its media attachments to a message)
public class MessageChatItemConverter : IChatItemConverter
{
public ChatItem ConvertToChatItem(object dataItem, ChatItemConverterContext context)
{
Message message = (Message)dataItem;
if (message.IsMMS.HasValue && message.IsMMS.Value == true)
{
var newMediaMessage = new ImageMessage()
{
ImageSource = null,
Author = message.IsInbound.HasValue && message.IsInbound.Value ? message.Conversation?.ContactAuthor : message.Conversation?.MtiAuthor,
Text = string.Empty,
Data = message,
};
if (message.Media?.Count > 1)
{
Utilities.MainThreadMessage("Warning", $"Multiple media messages are not supported: {message.MessageID} ({message.Media.Count})");
}
else if (message.Media?.Count == 0)
{
Utilities.MainThreadMessage("Warning", $"No media loaded: {message.MessageID}");
}
else
{
byte[]? imageBytes = message.Media?[0]?.ImageBytes;
if (imageBytes == null)
{
Utilities.MainThreadMessage("Warning", $"No image bytes loaded: {message.MessageID}");
}
else
{
newMediaMessage.ImageSource = ImageSource.FromStream(() => new MemoryStream(imageBytes));
}
}
return newMediaMessage;
}
TextMessage textMessage = new TextMessage()
{
Data = message,
Text = (message.IsMMS.HasValue && message.IsMMS.Value == true) ? "<Media Message>" : string.IsNullOrEmpty(message.Body) ? "<No Message>" : message.Body,
Author = message.IsInbound.HasValue && message.IsInbound.Value ? message.Conversation?.ContactAuthor : message.Conversation?.MtiAuthor,
};
return textMessage;
}
Hello Luke,
Thank you for the provided details.
I am not sure I understand what is the scenario you are looking for. Could you please send me images of the final result you want to achieve?
I noticed you open only forum threads. You can also open support tickets. Could you please share why you use the forum instead of opening support tickets?
Regards,
Didi
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.