setConversationDraft static method

Future<V2TimCallback> setConversationDraft({
  1. required String conversationID,
  2. String? draftText,
})

Implementation

static Future<V2TimCallback> setConversationDraft({
  required String conversationID,
  String? draftText,
}) async {
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  int conv_type = Tools.convertid2convType(conversationID);
  Pointer<Uint8> conv_id = Tools.string2PointerInt8(Tools.nativecidtoCcid(conversationID));
  print(json.encode(Map<String, dynamic>.from({"draft_edit_time": (DateTime.now().millisecondsSinceEpoch / 1000).floor(), "draft_msg": draftText})));
  Pointer<Uint8> json_draft_param = Tools.string2PointerInt8(json.encode(Map<String, dynamic>.from({"draft_edit_time": (DateTime.now().millisecondsSinceEpoch / 1000).floor(), "draft_user_define": draftText})));
  int res = desktopSDK.D_TIMConvSetDraft(conv_id, conv_type, json_draft_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimCallback.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    return V2TimCallback.fromJson({
      "code": data["code"],
      "desc": data["desc"],
    });
  }
}