fetchConversationListFromServer method

  1. @Deprecated('Use [fetchConversationsByOptions] instead')
Future<List<ChatConversation>> fetchConversationListFromServer({
  1. int pageNum = 1,
  2. int pageSize = 20,
})

获取服务器会话列表。

Param pageNum 当前页码。

Param pageSize 每页期望返回的会话数量。

Return 当前用户的会话列表。

Throws 如果有异常会在这里抛出,包含错误码和错误描述,详见 ChatError

Implementation

@Deprecated('Use [fetchConversationsByOptions] instead')

///
/// 获取服务器会话列表。
///
/// Param [pageNum] 当前页码。
///
/// Param [pageSize] 每页期望返回的会话数量。
///
/// **Return** 当前用户的会话列表。
///
/// **Throws**  如果有异常会在这里抛出,包含错误码和错误描述,详见 [ChatError]。
Future<List<ChatConversation>> fetchConversationListFromServer({
  int pageNum = 1,
  int pageSize = 20,
}) async {
  try {
    Map request = {
      "pageNum": pageNum,
      "pageSize": pageSize,
    };
    Map result = await platform_interface.Client.instance.chatManager.callNativeMethod(
        ChatMethodKeys.fetchConversationsFromServerWithPage, request);
    ChatError.hasErrorFromResult(result);
    List<ChatConversation> conversationList = [];
    result[ChatMethodKeys.fetchConversationsFromServerWithPage]
        ?.forEach((element) {
      conversationList.add(ChatConversation.fromJson(element));
    });
    return conversationList;
  } catch (e) {
    rethrow;
  }
}