getMessageSummary static method
String
getMessageSummary({
- V2TimMessage? message,
- int? messageReceiveOption,
- int? unreadCount,
- String? draftText,
- bool needStatus = true,
Implementation
static String getMessageSummary(
{V2TimMessage? message, int? messageReceiveOption, int? unreadCount, String? draftText, bool needStatus = true}) {
String text = "";
if (message != null) {
switch (message.elemType) {
case MessageElemType.V2TIM_ELEM_TYPE_TEXT:
if (message.textElem != null) {
text = message.textElem!.text ?? "";
}
break;
case MessageElemType.V2TIM_ELEM_TYPE_CUSTOM:
final (String lineOne, String? lineTwo) = handleCustomMessage(message);
text = lineTwo != null ? "$lineOne: $lineTwo" : lineOne;
break;
case MessageElemType.V2TIM_ELEM_TYPE_SOUND:
text = "[${tL10n.audio}]";
break;
case MessageElemType.V2TIM_ELEM_TYPE_FACE:
text = '[${tL10n.sticker}]';
break;
case MessageElemType.V2TIM_ELEM_TYPE_FILE:
text = '[${tL10n.file}]';
break;
case MessageElemType.V2TIM_ELEM_TYPE_GROUP_TIPS:
text = "[${tL10n.groupTips}]${buildGroupTipsText(message.groupTipsElem)}";
break;
case MessageElemType.V2TIM_ELEM_TYPE_IMAGE:
text = '[${tL10n.image}]';
break;
case MessageElemType.V2TIM_ELEM_TYPE_VIDEO:
text = '[${tL10n.video}]';
break;
case MessageElemType.V2TIM_ELEM_TYPE_LOCATION:
text = '[${tL10n.location}]';
break;
case MessageElemType.V2TIM_ELEM_TYPE_MERGER:
text = '[${tL10n.chatHistory}]';
break;
default:
text = "";
}
if (message.status == 4 && needStatus) {
text = tL10n.messageDeleted;
}
if (message.status == 6 && needStatus) {
if (message.revokerInfo != null && TencentCloudChatUtils.checkString(message.revokerInfo?.userID) != null) {
text = tL10n.memberRecalledMessage(
TencentCloudChatUtils.checkString(message.revokerInfo?.nickName) ?? message.revokerInfo!.userID!);
} else {
text = tL10n.messageRecalled;
}
}
if (messageReceiveOption != 0) {
if (unreadCount != null) {
if (unreadCount > 0) {
text = "[${tL10n.unreadCount(unreadCount)}]$text";
}
}
}
if (TencentCloudChatUtils.checkString(draftText) != null) {
text = "";
}
}
return text;
}