formateParams static method

dynamic formateParams(
  1. Map<String, dynamic> data
)

Implementation

static formateParams(Map<String, dynamic> data) {
  // int getType = HistoryMessageGetType.V2TIM_GET_LOCAL_OLDER_MSG,
  // String? userID,
  // String? groupID,
  // int lastMsgSeq = -1,
  // required int count,
  // List<int>? messageTypeList, // web暂不处理
  // String? lastMsgID,
  // List<int>? messageSeqList,
  // int? timeBegin,
  // int? timePeriod,

  Map<String, dynamic> params = <String, dynamic>{};
  final groupID = data['groupID'] ?? '';
  final userID = data['userID'] ?? '';
  int? seq = data["lastMsgSeq"];
  int? time = data["timeBegin"];
  int getType = data["getType"];
  final convType = groupID != '' ? 'GROUP' : 'C2C';
  final sendToUserID = convType == 'GROUP' ? groupID : userID;
  final haveTwoValues = groupID != '' && userID != '';
  if (haveTwoValues) {
    return null;
  }

  params["conversationID"] = convType + sendToUserID;
  params["count"] = data["count"];
  params["nextReqMessageID"] = data["lastMsgID"];
  if (seq != null && seq != -1) {
    params["sequence"] = seq;
  }
  if (time != null) {
    params["time"] = time;
  }
  if (getType == 1 || getType == 3) {
    params["direction"] = 0;
  } else {
    params["direction"] = 1;
  }
  return mapToJSObj(params);
}