getTopicInfoList method
Implementation
Future<V2TimValueCallback<List<V2TimTopicInfoResult>>> getTopicInfoList({
required String groupID,
required List<String> topicIDList,
}) async {
try {
final res = await wrappedPromiseToFuture(timeweb!.getTopicList(
mapToJSObj({"groupID": groupID, "topicIDList": topicIDList})));
var code = res.code;
var result = jsToMap(res.data);
var successTopicResult = result["successTopicList"] as List;
var failedTopicResult = result["failureTopicList"] as List;
if (code == 0) {
final formatedSuccessResult = List.empty(growable: true);
final formatedFailureResult = List.empty(growable: true);
for (var element in successTopicResult) {
final item = jsToMap(element);
final formatedMessage = await GetConversationList.formateLasteMessage(
jsToMap(item["lastMessage"]));
final formatedItem = {
"topicInfo": {
"topicID": item["topicID"],
"topicName": item["topicName"],
"topicFaceUrl": item["avatar"],
"introduction": item["introduction"],
"notification": item["notification"],
"isAllMute": item["muteAllMembers"],
"selfMuteTime": jsToMap(item["selfInfo"])["muteTime"],
"customString": item["customData"],
"recvOpt": GroupRecvMsgOpt.convertMsgRecvOpt(
jsToMap(item["selfInfo"])["messageRemindType"]),
"unreadCount": item["unreadCount"],
"lastMessage": formatedMessage,
"groupAtInfoList": GetConversationList.formateGroupAtInfoList(
item["groupAtInfoList"])
}
};
formatedSuccessResult.add(formatedItem);
}
for (var element in failedTopicResult) {
final item = jsToMap(element);
final formatedMessage = await GetConversationList.formateLasteMessage(
jsToMap(item["lastMessage"]));
final formatedItem = {
"errorCode": element["code"],
"errorMessage": element["message"],
"topicInfo": {
"topicID": element["topicID"],
"topicName": element["topicName"],
"topicFaceUrl": element["avatar"],
"introduction": element["introduction"],
"notification": element["notification"],
"isAllMute": element["muteAllMembers"],
"selfMuteTime": jsToMap(element["selfInfo"])["muteTime"],
"customString": element["customData"],
"recvOpt": GroupRecvMsgOpt.convertMsgRecvOpt(
jsToMap(element["selfInfo"])["messageRemindType"]),
"unreadCount": element["unreadCount"],
"lastMessage": formatedMessage,
"groupAtInfoList": GetConversationList.formateGroupAtInfoList(
element["groupAtInfoList"])
}
};
formatedSuccessResult.add(formatedItem);
}
return CommonUtils.returnSuccess<List<V2TimTopicInfoResult>>(
[...formatedSuccessResult, ...formatedFailureResult]);
} else {
return CommonUtils.returnErrorForValueCb<List<V2TimTopicInfoResult>>(
"getTopicInfoList Failed");
}
} catch (error) {
return CommonUtils.returnErrorForValueCb<List<V2TimTopicInfoResult>>(
error.toString());
}
}