formateConversationListItem static method

dynamic formateConversationListItem(
  1. Map<String, dynamic> itemJS
)

Implementation

static formateConversationListItem(Map<String, dynamic> itemJS) async {
  Map<String, dynamic> conversationListItem = itemJS;
  final originalConversationID = itemJS['conversationID'] as String;
  var formatedConversationID = "";
  formatedConversationID = originalConversationID.replaceAll("C2C", "c2c_");
  formatedConversationID =
      formatedConversationID.replaceAll("GROUP", "group_");

  conversationListItem["friendRemark"] = itemJS['remark'];
  conversationListItem["isPinned"] = itemJS['isPinned'];
  conversationListItem["recvOpt"] =
      GroupRecvMsgOpt.convertMsgRecvOpt(itemJS["messageRemindType"] ?? "");
  conversationListItem["conversationID"] = formatedConversationID;
  if (itemJS['lastMessage'] != null) {
    conversationListItem["lastMessage"] = await formateLasteMessage(
        jsToMap(itemJS['lastMessage']),
        groupID: itemJS['conversationID']);
  }

  // 这个是web特有,其中的属性,在ios都是外层
  if (itemJS['groupProfile'] != null) {
    final groupProfile = jsToMap(itemJS['groupProfile']);
    conversationListItem["groupProfile"] =
        await formateGroupProfile(groupProfile);
    conversationListItem["groupID"] = groupProfile['groupID'];
    conversationListItem["showName"] = getShowName(itemJS);
    conversationListItem["groupType"] = groupProfile['type'];
    conversationListItem["faceUrl"] = groupProfile['avatar'];
  }
  if (itemJS['groupAtInfoList'] != null &&
      itemJS['groupAtInfoList'].length > 0) {
    conversationListItem["groupAtInfoList"] =
        formateGroupAtInfoList(itemJS['groupAtInfoList']);
  }
  if (itemJS['userProfile'] != null) {
    final userProfile = jsToMap(itemJS['userProfile']);
    conversationListItem["userProfile"] = formateUserProfile(userProfile);
    conversationListItem["userID"] = userProfile['userID'];
    conversationListItem["showName"] = getShowName(itemJS);
    conversationListItem["faceUrl"] = userProfile['avatar'];
  }
  conversationListItem["type"] =
      ConversationTypeWeb.convertConverstationtType(itemJS["type"]);
  conversationListItem["orderkey"] = 0;
  return conversationListItem;
}