getFriendApplicationList static method
Future<V2TimValueCallback<V2TimFriendApplicationResult>>
getFriendApplicationList(
)
Implementation
static Future<V2TimValueCallback<V2TimFriendApplicationResult>> getFriendApplicationList() async {
String param = json.encode({
"friendship_get_pendency_list_param_type": 2,
"friendship_get_pendency_list_param_start_seq": 0,
"friendship_get_pendency_list_param_limited_size": 1000,
});
String userData = Tools.generateUserData();
Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
Pointer<Uint8> json_get_pendency_list_param = Tools.string2PointerInt8(param);
int res = desktopSDK.D_TIMFriendshipGetPendencyList(json_get_pendency_list_param, user_data);
if (res != TIMResult.TIM_SUCC) {
return V2TimValueCallback<V2TimFriendApplicationResult>.fromJson({
"code": res,
"desc": "",
});
} else {
Map<String, dynamic> data = await getAsyncData(apiKey: userData);
print(data);
Map<String, dynamic> nativeJson = Map<String, dynamic>.from(json.decode(data["json_param"].isEmpty ? json.encode({}) : data["json_param"]));
List<Map<String, dynamic>> appList = List<Map<String, dynamic>>.from(nativeJson["pendency_page_pendency_info_array"] ?? []);
List<Map<String, dynamic>> appListDart = List.empty(growable: true);
for (Map<String, dynamic> element in appList) {
appListDart.add(Map<String, dynamic>.from({
"userID": element["friend_add_pendency_info_identifier"],
"nickname": element["friend_add_pendency_info_nick_name"],
"faceUrl": "",
"addTime": element["friend_add_pendency_info_add_time"],
"addSource": element["friend_add_pendency_info_add_source"],
"addWording": element["friend_add_pendency_info_add_wording"],
"type": (element["friend_add_pendency_info_type"] ?? 0) + 1,
}));
}
Map<String, dynamic> dartJson = Map<String, dynamic>.from({
"unreadCount": nativeJson["pendency_page_unread_num"],
"friendApplicationList": appListDart,
"userID": nativeJson["friend_result_identifier"],
});
// V2TimFriendApplicationResult
return V2TimValueCallback<V2TimFriendApplicationResult>.fromJson({
"code": data["code"],
"desc": data["desc"],
"data": dartJson,
});
}
}