findMessages method

Future<V2TimValueCallback<List<V2TimMessage>>> findMessages({
  1. required List<String> messageIDList,
})

Implementation

Future<V2TimValueCallback<List<V2TimMessage>>> findMessages({
  required List<String> messageIDList,
}) async {
  try {
    final rawMessageList = messageIDList.map((e) async {
      final jsMessage = timeweb!.findMessage(e);

      final formatedMessage = await V2TIMMessage.convertMessageFromWebToDart(jsMessage);
      return formatedMessage;
    }).toList();
    final formatedMessageList = await Future.wait(rawMessageList);
    if (formatedMessageList.isNotEmpty) {
      if (formatedMessageList.any((element) => element["msgID"] == null)) {
        return V2TimValueCallback<List<V2TimMessage>>.fromJson({
          "code": -1,
          "desc": "message not found",
          "data": null,
        });
      }
    }
    return CommonUtils.returnSuccess<List<V2TimMessage>>(formatedMessageList);
  } catch (error) {
    return CommonUtils.returnErrorForValueCb(error.toString());
  }
}