convertConvInfo2Dart static method

Future<V2TimConversation> convertConvInfo2Dart(
  1. dynamic jsonConvInfo
)

Implementation

static Future<V2TimConversation> convertConvInfo2Dart(jsonConvInfo) async {
  // String? faceUrl;
  // String? groupType;
  var groupAtList = [];
  if (jsonConvInfo["conv_group_at_info_array"] != null) {
    for (Map<String, dynamic> groupinfo in jsonConvInfo["conv_group_at_info_array"]) {
      groupAtList.add(convertGroupAtInfo(groupinfo).toJson());
    }
  }

  // 这里获取下会话信息,和群信息~TODO
  return V2TimConversation.fromJson({
    "conversationID": Tools.ccidtoNativecid(
      jsonConvInfo["conv_id"],
      jsonConvInfo["conv_type"],
    ),
    "type": jsonConvInfo["conv_type"],
    "userID": jsonConvInfo["conv_type"] == 1 ? jsonConvInfo["conv_id"] : null,
    "groupID": jsonConvInfo["conv_type"] == 2 ? jsonConvInfo["conv_id"] : null,
    "unreadCount": jsonConvInfo["conv_unread_num"],
    "showName": jsonConvInfo["conv_show_name"],
    "isPinned": jsonConvInfo["conv_is_pinned"],
    "recvOpt": jsonConvInfo["conv_recv_opt"],
    "lastMessage": jsonConvInfo["conv_last_msg"] != null ? (await convertMessage2Dart(jsonConvInfo["conv_last_msg"])).toJson() : null,
    "draftText": Map<String, dynamic>.from(jsonConvInfo["conv_draft"] ?? {})["draft_user_define"],
    "customData": jsonConvInfo["conv_custom_data"],
    "markList": jsonConvInfo["conv_mark_array"],
    "conversationGroupList": jsonConvInfo["conv_conversation_group_array"],
    "groupAtInfoList": groupAtList,
    "orderkey": jsonConvInfo["conv_active_time"],
    "draftTimestamp": Map<String, dynamic>.from(jsonConvInfo["conv_draft"] ?? {})["draft_edit_time"],
    "c2cReadTimestamp": jsonConvInfo["conv_c2c_read_timestamp"],
    "groupReadSequence": jsonConvInfo["conv_group_read_sequence"],
  });
}