fetchJoinedChatThreadsWithParentId method

Future<ChatCursorResult<ChatThread>> fetchJoinedChatThreadsWithParentId({
  1. required String parentId,
  2. String? cursor,
  3. int limit = 20,
})

分页从服务器获取当前用户加入指定群组的子区列表。

Param parentId 群组 ID。

Param cursor 开始取数据的游标位置。首次调用方法时可以不传,按用户加入子区时间的倒序获取数据。

Param limit 每页期望返回的子区数。取值范围为 1,50

Return 若调用成功,返回子区列表;失败则抛出异常。

Throws 如果有异常会在此抛出,包括错误码和错误信息,详见 ChatError

Implementation

Future<ChatCursorResult<ChatThread>> fetchJoinedChatThreadsWithParentId({
  required String parentId,
  String? cursor,
  int limit = 20,
}) async {
  try {
    Map req = {
      "parentId": parentId,
      "pageSize": limit,
    };
    req.putIfNotNull("cursor", cursor);
    Map result = await platform_interface.Client.instance.chatThreadManager.callNativeMethod(
        ChatMethodKeys.fetchJoinedChatThreadsWithParentId, req);
    ChatError.hasErrorFromResult(result);
    return ChatCursorResult.fromJson(
        result[ChatMethodKeys.fetchJoinedChatThreadsWithParentId],
        dataItemCallback: (map) {
      return ChatThread.fromJson(map);
    });
  } catch (e) {
    rethrow;
  }
}