getHistoryMessage static method

Future<NIMResult<List<ChatMessage>>> getHistoryMessage(
  1. NIMMessage anchor,
  2. QueryDirection direction,
  3. int limit, {
  4. bool enablePin = true,
})

获取历史消息

Implementation

static Future<NIMResult<List<ChatMessage>>> getHistoryMessage(
    NIMMessage anchor, QueryDirection direction, int limit,
    {bool enablePin = true}) async {
  var msgRes = await NimCore.instance.messageService
      .queryMessageListEx(anchor, direction, limit);
  if (msgRes.isSuccess && msgRes.data != null) {
    List<ChatMessage> result = await fillUserInfo(msgRes.data!);
    if (enablePin) {
      result = _fillPin(anchor.sessionId!, anchor.sessionType!, result);
    }
    return NIMResult(msgRes.code, result, msgRes.errorDetails);
  } else {
    return NIMResult(msgRes.code, null, msgRes.errorDetails);
  }
}