getConversationListByConversaionIds static method

Future<V2TimValueCallback<List<V2TimConversation>>> getConversationListByConversaionIds({
  1. required List<String> conversationIDList,
})

Implementation

static Future<V2TimValueCallback<List<V2TimConversation>>> getConversationListByConversaionIds({
  required List<String> conversationIDList,
}) async {
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  List<Map<String, dynamic>> convIdList = List.empty(growable: true);
  for (String element in conversationIDList) {
    convIdList.add(Map.from({
      "get_conversation_list_param_conv_id": Tools.nativecidtoCcid(element),
      "get_conversation_list_param_conv_type": Tools.convertid2convType(element), // TODO,改造入参包含会话类型
    }));
  }
  Pointer<Uint8> json_get_conv_list_param = Tools.string2PointerInt8(json.encode(convIdList));

  int res = desktopSDK.D_TIMConvGetConvInfo(json_get_conv_list_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<List<V2TimConversation>>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
    List<V2TimConversation> convlist = List<V2TimConversation>.empty(growable: true);
    for (var element in dataList) {
      Map<String, dynamic> jso = element;

      V2TimConversation converInfo = await Tools.convertConvInfo2Dart(jso);
      convlist.add(converInfo);
    }
    return V2TimValueCallback<List<V2TimConversation>>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": await addConversationBaseInfoFromGroupAndUseraInfo(convlist),
    });
  }
}